I want to compare my variable from may form with the current date :
$a = explode('/', $request->expired_at); $expiredAt = str_replace('/', '-', jalali_to_gregorian($a[0], $a[1], $a[2], ':'));
my $expiredAt result -> “2021-03-25” -> insert by user in form
And my short if :
return Carbon::now()->toDateString() > $expiredAt ? false : true;
but this code returns null result.
Answer
Carbon should be able to parse expired_at
for you so you parse expired_at
and see whether now()
is greater.
return ! now()->greaterThan(Carbon::parse($request->expired_at));