denno020 Posted April 14, 2011 Share Posted April 14, 2011 (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 Quote Link to comment https://forums.phpfreaks.com/topic/233702-work-out-if-current-date-today-is-a-week-before-a-given-date/ Share on other sites More sharing options...
ignace Posted April 14, 2011 Share Posted April 14, 2011 $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!!!'; } Quote Link to comment https://forums.phpfreaks.com/topic/233702-work-out-if-current-date-today-is-a-week-before-a-given-date/#findComment-1201507 Share on other sites More sharing options...
denno020 Posted April 14, 2011 Author Share Posted April 14, 2011 So I literally write 'July 7 2011 - 1 week' for the string to time? Wow.. Thanks so much for the help ignace, I will implement it into my site right now . Thanks Denno Quote Link to comment https://forums.phpfreaks.com/topic/233702-work-out-if-current-date-today-is-a-week-before-a-given-date/#findComment-1201637 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.