I'm making a website, part which needs saves sales records for people each day. The client wants a page which shows the sales weekly in a table, so each row should start on Monday, and show each days sales for the week.
I used the code below to take a year and week number, and show the dates for Monday and Sunday, and it worked fine for December 08, but come 2009 it's just plain wrong.
2008
Week 51 - 15th Dec - 21st Dec
Week 52 - 22nd Dec - 28th Dec
2009
Week 1 - 3rd Jan - 9th Jan
Week 2 - 10th Jan - 16th Jan
15th and 22nd December are Mondays by my calendar, but the 3rd of January is a Saturday? I just don't get how this could work in December but not in January?
Anyone see something I can't? This has been driving me mad!
I used the code below to take a year and week number, and show the dates for Monday and Sunday, and it worked fine for December 08, but come 2009 it's just plain wrong.
2008
Week 51 - 15th Dec - 21st Dec
Week 52 - 22nd Dec - 28th Dec
2009
Week 1 - 3rd Jan - 9th Jan
Week 2 - 10th Jan - 16th Jan
15th and 22nd December are Mondays by my calendar, but the 3rd of January is a Saturday? I just don't get how this could work in December but not in January?
Anyone see something I can't? This has been driving me mad!
PHP:
$time = strtotime("4th January ".$year . ' +' . ($week - 1) . ' weeks');
$mondayTime = strtotime('-' . (date('w', $time) - 1) . ' days', $time);
$from = date('jS M', $mondayTime);
$to = date('jS M', strtotime('+ 6 days', $mondayTime));