Jump to content

Recommended Posts


$nextWeek = time() + (7 * 24 * 60 * 60);
                   // 7 days; 24 hours; 60 mins; 60secs
echo 'Now:       '. date('Y-m-d') ."\n";
echo 'Next Week: '. date('Y-m-d', $nextWeek) ."\n";
// or using strtotime():

echo 'Next Week: '. date('Y-m-d', strtotime('+1 week')) . ' 10:45AM';

voip03, that would output today's date and the date in a week's time.

use the example to write the code

Your example says nothing about "saturday" at all, the example does not pertain to the question that was asked.

 

OP: The strtotime solution is the best one, however, as he said, strtotime is a tricky beast.  You may want to use:

strtotime('+1 saturday')

 

-Dan

Thanks Guru!

 

I thought it would be more complicated.

What is the tricky stuff with strtotime() ?

Adam's name is Adam, his title is Guru ;-)

 

The tricky stuff comes from the interpretations of "next" and "last".  For instance, if I ask for "next wednesday" I get 7 days from now.  If I ask for "thursday" or "next thursday" I get tomorrow.  The definition of "next" for the computer is "the next occurring one."  The definition of "next" in common parlance is "the one during next week."  Sometimes strtotime produces results you don't expect, so I'd test this for a week's worth of days to make sure it always returns the right dates before releasing it.

 

-Dan

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.