lundi 5 novembre 2018

DateTime - If condition return true if equals

I have a simple problem. I want to check if twi two DateTime are equals or not (same day - not same timestamp) but i have an erro from Laravel

Call to a member function format() on boolean

It's my code :

$date_historique = DateTime::createFromFormat('d-m-Y',$myInputDate)->format('d m Y');

foreach ($trips as $trip) {
     $date_verif= DateTime::createFromFormat('U',$trip->startTs/1000)->format('d m Y');

     if((string)$date_verif == (string)$date_historique){
         //code
     }

}

Thank you ;)

Aucun commentaire:

Enregistrer un commentaire