How to compare a string with carbon date if more than or less than?
Is it correct to compare between string date and carbon date?
$today = Carbon::today();
$date= '22-7-2017';
if($date > $today){
//.....
}
No, you need to instantiate $date as Carbon object, and then you can compare 2 values
$date1 =Carbon::parse($date);
$today = Carbon::now();
I wouldn't suggest it as you are likely to get false positives.
I would parse your string date and make it a Carbon object also and then do the compare.
So:
$date = Carbon::parse('22-7-2017');
Hope that helps.
Please or to participate in this conversation.