Hi,
currently I have the problem, that I am looking for a function which returns the beginning an the End of a certain week of the year.
Say, I call the function getKWBeginEnd(35, 2001),
i want to get back list(20010827000000, 20010902000000).
Here is my solution:
function getKWBeginEnd($KW, $year)
{
$i = 0;
// The 400 are just to make sure we don't end up in an infinate loop.
//
while ( $i < 400 && $KW!=strftime("%V", mktime(1, 1, 1, 1, $i, $year)) ) {
$i++;
}
$begin = date("Ymd000000", mktime(1,1,1,1,$i, $year) );
$ende = date("Ymd000000", mktime(1,1,1,1,$i+6, $year) );
return array($begin, $ende);
}
Works fine so far, except for 1 date:
Week 52, in the year 2000.
I always get list(19991231000000, 20000106000000) as a return
which is definately wrong. Week 52 in the year 2000 is from
20001225 thru 20001231.
Who can help? I don't want to make this function overly complicated,
since it is called several throughout the site.
Thanks a lot,
Oliver