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

thebigk's avatar
Level 13

Carbon - format date as : "Today, 11:35 am"?

I wish to display date on my posts as "Today, 11:35 am". How can I do that with Carbon library?

0 likes
2 replies
CorvS's avatar
CorvS
Best Answer
Level 27

@thebigk Maybe calendar() is what you are looking for?

{{ now()->calendar() }} // Today at 7:45 AM

Alternatively you could work with isToday() and format().

{{ $date->isToday() ? 'Today, ' : 'Whatever' }}
{{ $date->format('g:i a') }} // 7:45 am
1 like
thebigk's avatar
Level 13

That's awesome! I could not find calendar() myself. Searched the Carbon documentation twice!

1 like

Please or to participate in this conversation.