Jump to content

Printing months and weeks


Canman2005

Recommended Posts

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

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

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.

<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.

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.