Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 - Check if date is today

Tags:

date

laravel

I'm creating a timeline and I'm nearly finished. I want that the color of the date for each timeline event is the same beside if the date is "today".

So I need something like:

@if($event[$i]->created_at->format('d.m.Y') == *code or variable that says its today*)
     ....
@endif

But I couldn't figure out what I can do to save the todays date in a variable.. Does anybody knows a solution for this?

thanks!

like image 985
WellNo Avatar asked Oct 26 '16 08:10

WellNo


1 Answers

You can use isToday() method to check if date is today:

if ($event[$i]->created_at->isToday())
like image 87
Alexey Mezenin Avatar answered Sep 17 '22 16:09

Alexey Mezenin