lundi 30 avril 2018

Laravel Eloquent compare dates by specific format

I am having a little trouble comparing dates in Laravel, where the date is a specific format. The field in the database has the date like this d-m-Y(20-04-2018) and I am trying to get a result where this date is greater than the date now using this.

$check= Usersubstitutions::where([
   ['user_id', '=', $request->user],
   ['date_to', '>=', date("d-m-Y")]
])->first();

And it never works. I var dumped to see what compares, using a foreach and it says that 20-05-2018 is NOT greater than 04-04-2018.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire