There is a string of the form '2016-07-25 18:14:00' How to determine whether the date has come or not?

    3 answers 3

    You can do the following:

    <?php $date = new DateTime('2016-07-25 18:14:00'); $now = new DateTime(); if($date < $now) echo 'Дата наступила'; echo 'Дата не наступила'; 

      You can use the strtotime function which will bring your string to the Unix timestamp, and then compare the result with the result obtained from the time() function

         $now = new DateTime(); $diff = $now->diff('дата'); if($diff->invert) //прошедшее время else //будущее время