Check If A Date Is In The Past Or In The Future in PHP

0
552

The following code will help you to check if a date in the future or in the past. Where are this required? A lot of fields date will require you to check if the date is in the past or in the future.

$time = "2017-09-26";
if(strtotime($time) > time()) {
     //in the future
}

if(strtotime($time) < time()) {
     //in the past
}

if(strtotime($time) == time()) {
    //is right now
}

 

LEAVE A REPLY

Please enter your comment!
Please enter your name here