Try simply this-
$date = new Carbon;
if($date > $product->expirey_date)
{
//its already expired
} else {
//stil to go
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am using the method below to get the difference between day but it always show positive value even if the today date is greater than expiry date. I want to compare the date to know whether the product is expired or not.
var day = "{{(Carbon\Carbon::parse($product->expiry_date)->diffInDays(Carbon::now()))}}";
Please or to participate in this conversation.