$end_date = "12.05.2016-00:00"; if($end_date > date('dmY-H:i')) { echo "1"; } else { echo "0"; } 

He must issue 1 and put 0, if you use another date for example: 05/20/2016-00: 00 then he puts 1

  • Are the time zones set up? - AntonioK
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

2 answers 2

These are strings! You do not compare the dates themselves, but the strings by the string comparison rules. Compare time stamps:

 $end_date = strtotime("12.05.2016-00:00"); if($end_date > strtotime("now")) { echo "1"; } else { echo "0"; } 
  • Thank you, earned) - Test11111

You can try using datetime . It will be something like this:

 $format = 'dmY-H:i'; $end_date= DateTime::createFromFormat($format, '12.05.2016-00:00'); $now = new DateTime(); if($now < $end_date){ return true; } return false; 
  • Your format is not correct here, please correct it with $format = 'dmY-H:i'; - user200141
  • This option is more accurate, the time is also compared - Test11111