mercredi 7 décembre 2016

Check if a date is equal to other date using Laravel 5.3

I am trying to check if one date is equal than the other date, but I can't get the match because the date format coming from the form turns into a different order once it gets through the "parse" code. I need to format this date to find the match, here is a sample code to show how I am trying:

 ...

 // $ago will give me this date: 2016-12-09 00:00:00
 $ago = Carbon\Carbon::today()->addDays(5); // Todays date + 5 days

 //$request->datex has the date coming from a form with this format, '12-06-2016'.

 // Once a parse $request->datex here, the date gets out of order:
 $my_date = Carbon\Carbon::parse($request->datex);
 // it shows the date like this, 2016-09-12 00:00:00 , I need it to be on this format: 2016-12-09 00:00:00

 // then I could do this:

 if ( $ago$ == $my_date ) {

  dd($my_date.' is equal to: '.$ago );

 }else{

  dd(' Not equal!');

 }
 ...

Thanks for looking!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire