Week #'s don't match PHP to Java
I am rewriting a database front end that was previously done in Java. I've created the below function to return 52 weeks of work week values for the user to select a specific work week to request a time sheet for (I am aware it won't fully function as I will be returning too much data in my option values, but that is an easy fix, just haven't done it yet.
My dilemma (and this may be a moot point after I discuss it with the client tomorrow, but I'd still like an answer just for my own well being. Is that the code the previous person used is returning week #46 (11/05/12) where my code is returning that same week as week #45 with the same base date.
Hopefully someone might have a suggestion for me to explain the discrepancy between the week number variance?
PHP Code:
// Build a list of the past 52 work weeks (Monday is basis)
function GetWorkWeeks()
{
$FullWeek = 7;
$StartDate = strtotime('Monday this week');
$StartWeek = date('W (m-d-Y)', $StartDate);
$WorkWeeks = "<option value='" . $StartWeek . "' selected>" . $StartWeek . "</option>" . "\n";
while ($FullWeek < 365)
{
$StartDate = strtotime("Monday this week -$FullWeek days");
$StartWeek = date('W (m-d-Y)', $StartDate);
$WorkWeeks .= "<option value='" . $StartWeek . "'>" . $StartWeek . "</option>" . "\n";
$FullWeek = $FullWeek + 7;
}
return $WorkWeeks;
}