Jump to content

Work out if current date (today) is a week before a given date


Recommended Posts

(continuing from topic title)

So if I set a date of July 7 2011 into my script, hard coded in, I would like the current date to be checked against the hard coded date, and return true if the current date is within a week leading up to the hard coded date.

 

How could I go about doing this easily?

 

I've been researching dates in php but I can't seem to work out the best way to achieve what I'm after.

 

Cheers

Denno

$then = strtotime('July 7 2011 - 1 week'); // such power at the tip of your fingers
$final = strtotime('July 7 2011');
$now = time();
if($now < $then) {
    echo 'just a little longer..';
} else if($now >= $then && $now < $final) {
    echo 'almost there.. almost there..';
} else if($now == $final) {
    echo 'celebrate good times com\'on!!';
} else {
    echo 'phew, what a PARTYYYY!!!';
}

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.