I hope somebody can help me here. It has been awhile since I programmed in PHP everyday.
I need a function that takes the date and returns the week number of the year. For example you would pass the date 2005-06-19 and it would return 25. I started with a working calendar script and tried to tweak it to return the week number. It worked for a while then for some unknow reason (i must have done something) it would start repeating the date 10-30. Here is what I have so far. Also note that the find date code is not in place here.
This script is by no means optimized.
<?php
$week = date2wk("2005","1","2","2005","6","18"); // should return 24 $week = 24
function date2wk($year, $month, $day, $find_year, $find_month, $find_day)
{
$x=0;
for ($wk = 1; $wk <= 53; $wk++)
{
for ($b = 1; $b <= 7; $b++)
{
$date = mktime("","","",$month, $day, $year);
echo date('Y-m-d',$date) . "\r\n";
echo " $x<br>\r\n";$x++;
$newtime = getdate($date + (60*60*24));
$year = $newtime["year"];
$month = $newtime["mon"];
$day = $newtime["mday"];
}
}
}
?>