Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

XanderLaravel's avatar

Carbon diffForHumans() - replace seconds with "just now"

When I use

{{ $message->created_at->diffForHumans() }}

with livewire I can see it count up in seconds until 1 minute then it changes every minute. Is there a way I can instead of the first 60 seconds say "just now" and than the minutes?

0 likes
1 reply
Niush's avatar
Niush
Best Answer
Level 50

Like this:

{{ $message->created_at->diffInSeconds() < 60 ? 'just now' : $message->created_at->diffForHumans() }}

Instead if you wanted just now only for first one second, there is built in way:

{{ $message->created_at->diffForHumans(['options' => \Carbon\Carbon::JUST_NOW]) }}
1 like

Please or to participate in this conversation.