Jump to content

Printing every week


Canman2005

Recommended Posts

Hi all

 

Im wondering if anyone can help me, basically im trying to print a list of every Friday since a date defined.

 

Let me try and explain.

 

I want to define a date such as 2007-07-06 (which is a Friday) and then let php print each Friday since that date until today.

 

For example, if the date defined was 2007-07-06 then it would print

 

2007-07-06

2007-07-13

2007-07-20

2007-07-27

2007-08-03

2007-08-10

2007-08-17

2007-08-24

2007-08-31

2007-09-07

2007-09-14

 

But I want to also be able to format the date it outputs, so it might look like

 

Friday 06 July 2007

Friday 13 July 2007

Friday 20 July 2007

 

and so on

 

Can anyone help me?

 

Thanks in advance

 

Ed

Link to comment
https://forums.phpfreaks.com/topic/69606-printing-every-week/
Share on other sites

You can do some sort of function usign the start day and then basically say

 

$day = mktime(nextfriday, $dateentered);

 

then say

while($day < $today){

$day = mktime(nextfriday, $day);

//Format $day to your need and print

}

 

 

There is a time flag called Next Day of the week, I had a list of em somewhere but this is the just

Link to comment
https://forums.phpfreaks.com/topic/69606-printing-every-week/#findComment-349786
Share on other sites

Formatting is done with the date() function.

 

You can use strtotime() and add 1 week to get the next friday.  For example, date('Y-m-d', strtotime('2007-09-01 +1 week')).  I'm not sure how that handles DST changes, but it's probably ok..

 

To find the first friday, you can use strtotime()'s other features like 'next Friday'

Link to comment
https://forums.phpfreaks.com/topic/69606-printing-every-week/#findComment-349845
Share on other sites

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.