fork download
  1. <?php
  2.  
  3. $dateFromDatabase = new DateTime('2016-05-23 17:00:00');
  4. $current = new DateTime();
  5.  
  6. $difference = $current->diff($dateFromDatabase);
  7.  
  8. if ($difference->format('%R') === '-') {
  9. echo 'Date is in the past';
  10. }
  11.  
Success #stdin #stdout 0.03s 52480KB
stdin
Standard input is empty
stdout
Date is in the past