Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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