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?

谢谢

推荐答案

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

if ($event[$i]->created_at->isToday())

Laravel相关问答推荐

从8.0更新到10.0后,图像不再上传到存储

Vue 组件中的图像不适用于 Vite + Laravel

自从 Laravel 使用 Vite 更新后,我无法运行npm run dev

使用Laravel Blade Formatter和PHP Intelephense进行 VSCode 格式化

Laravel 在维护模式下显示自定义消息

Laravel 5.7 判断Electron邮件是否经过验证

Laravel 5 日志(log)中的最大文件数

Laravel:如何在没有数据库的情况下对用户进行身份验证

Laravel:每当我返回一个模型时,总是返回一个与它的关系

Laravel whereDoesntHave() - 多个 OR 条件

Laravel vagrant up 不工作 - Errno::EADDRNOTAVAIL

WhereNotExists Laravel Eloquent

Laravel Mail 发送Electron邮件但返回 false

如何在 laravel 中使用 GROUP_CONCAT

Laravel Passport 通过访问令牌获取客户端 ID

Laravel Eloquent模型如何从关系表中获取数据

Laravel 5.4 - Mix - 如何运行浏览器实时重新加载

获取多列字段?

是否可以在 Laravel 的不同数据库中引用外键?

为什么 phpunit 没有得到 phpunit.xml 中指定的正确 APP_ENV?