Canman2005 Posted November 8, 2008 Share Posted November 8, 2008 Hi all Is it easy to print a list of months starting from a date set by $start = 2008-09-01; so it displays September 2008 October 2008 November 2008 December 2008 then print the weeks under each month, so it would look like September 2008 Week 1 - 2008-09-01 Week 2 - 2008-09-08 Week 3 - 2008-09-15 Week 4 - 2008-09-22 Week 5 - 2008-09-29 October 2008 Week 1 - 2008-10-01 Week 2 - 2008-10-08 Week 3 - 2008-10-15 Week 4 - 2008-10-22 Week 5 - 2008-10-29 thanks Link to comment https://forums.phpfreaks.com/topic/131952-printing-months-and-weeks/ Share on other sites More sharing options...
AndyB Posted November 8, 2008 Share Posted November 8, 2008 Please clarify what you really want. In your example, the first week of October should begin with [Monday] 2008-10-06 shouldn't it? I assume you want Mondays to be the first day of the week, but confirm that, too. Link to comment https://forums.phpfreaks.com/topic/131952-printing-months-and-weeks/#findComment-685608 Share on other sites More sharing options...
Canman2005 Posted November 8, 2008 Author Share Posted November 8, 2008 I just need to show each week in each month and then show the date next to it Link to comment https://forums.phpfreaks.com/topic/131952-printing-months-and-weeks/#findComment-685621 Share on other sites More sharing options...
Canman2005 Posted November 8, 2008 Author Share Posted November 8, 2008 Please clarify what you really want. In your example, the first week of October should begin with [Monday] 2008-10-06 shouldn't it? I assume you want Mondays to be the first day of the week, but confirm that, too. It would be helpful to also do this if you can help Link to comment https://forums.phpfreaks.com/topic/131952-printing-months-and-weeks/#findComment-685625 Share on other sites More sharing options...
AndyB Posted November 8, 2008 Share Posted November 8, 2008 Perhaps I wasn't clear about that. While the first seven days of October 2008 do begin at 2008-10-01, conventional thinking is that the first week of October actually begins on Monday October 6. Before anyone dashes off some code ... and a few minutes reviewing how the date() function works would help ... you need to define clearly what you really want. Link to comment https://forums.phpfreaks.com/topic/131952-printing-months-and-weeks/#findComment-685634 Share on other sites More sharing options...
Barand Posted November 8, 2008 Share Posted November 8, 2008 <Off topic> I can only speak for myself, but if ask for clarification of requirements, or the output from a specific piece of code, and get a negative or unhelpful response I immediately unsubscribe from that thread. We're willing to help but sometimes we need a bit of help from the OP to solve a problem. I think you are lucky Andy is still in there. Link to comment https://forums.phpfreaks.com/topic/131952-printing-months-and-weeks/#findComment-685642 Share on other sites More sharing options...
Canman2005 Posted November 8, 2008 Author Share Posted November 8, 2008 Okay, I shall read the date() info pn php.net thanks Link to comment https://forums.phpfreaks.com/topic/131952-printing-months-and-weeks/#findComment-685656 Share on other sites More sharing options...
Barand Posted November 8, 2008 Share Posted November 8, 2008 You should also look at strtotime(), particularly the section using this syntax: strtotime ("+7 days", $timestamp) Link to comment https://forums.phpfreaks.com/topic/131952-printing-months-and-weeks/#findComment-685663 Share on other sites More sharing options...
Canman2005 Posted November 8, 2008 Author Share Posted November 8, 2008 Thanks I have had a look, I see you can get the last monday by using date("d/m/Y",strtotime("last Monday")); but how would you say monday before last and the monday before that etc, can you just do date("d/m/Y",strtotime("last Monday")); and then run a -7 days? Link to comment https://forums.phpfreaks.com/topic/131952-printing-months-and-weeks/#findComment-685724 Share on other sites More sharing options...
AndyB Posted November 9, 2008 Share Posted November 9, 2008 ... can you just do ... First you try, then we help Link to comment https://forums.phpfreaks.com/topic/131952-printing-months-and-weeks/#findComment-685780 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.