I'm trying to compare 2 dates, by PHP's documentation :
$date1 = new DateTime("now");
$date2 = new DateTime("tomorrow");
var_dump($date1 > $date2); //false
So now is not bigger than tomorrow, so it's false. Now I have this :
$date_start = \DateTime::createFromFormat('d/m/Y H:i', '18/07/2018 16:20');
$date_start_format = $date_start->format('d/m/Y H:i');
$date_end = \DateTime::createFromFormat('d/m/Y H:i', '01/08/2018 21:45');
date_end_format = $date_end->format('d/m/Y H:i');
var_dump($date_start_format > $date_end_format); //True
Now when I try to compare an ancient date, with tomorrow, like in the example, I get true. Which should return false, can someone please explain why?
true. That's why dates are compared in theY-m-dformat when they are strings.format()was returning them as strings, thank you!