PHP check if timestamp is greater than 24 hours from now

Naterade picture Naterade · Jul 13, 2013 · Viewed 32k times · Source

I have software that needs to determine if the cutoff datetime is greater than 24 hours from now. Here is the code I have to test that.

 $date = strtotime("2013-07-13") + strtotime("05:30:00");

 if($date > time() + 86400) {
    echo 'yes';
 } else {
    echo 'no';
 }

My current date and time is 2013-07-13 2am. As you can see its only 3 hours away. At my math thats 10800 seconds away. The function I have is returning yes. To me this is saying the $date is greater than now plus 86400 seconds when in fact its only 10800 seconds away. Should this not be returning no?

Answer

Yogesh Suthar picture Yogesh Suthar · Jul 13, 2013
$date = strtotime("2013-07-13") + strtotime("05:30:00");

should be

$date = strtotime("2013-07-13 05:30:00");

See difference in this CodePad