How could I display today instead of date
Hello, how can I display today instead of date in blade laravel? Can this be done?
Try:
{{Carbon\Carbon::today()->format('d-M-Y')}}
If would you like short name today:
{{ \Carbon\Carbon::now()->format("D") }} // Thu
or full name
{{ \Carbon\Carbon::now()->format("l") }} // Thursday
or full date
{{ \Carbon\Carbon::now()->format("Y-m-d H:i:s") }} // 2020-09-10 09:01:44
For example if the post is made today to show "Today" after the following days
if i have in created_at today date
{{Carbon\Carbon::parse($post->created_at)->format('your_format')}}
@if( Carbon\Carbon::today()->format('d-M-Y') == Carbon\Carbon::parse($post->created_at)->format('D-M-Y') )
<span>Today</span>
@else
{{ Carbon\Carbon::parse($post->created_at)->format('d-m-Y') }}
</div>
@endif```
that's what I'm talking about
Ok, then keep the formats equal:
@if( Carbon\Carbon::today()->format('Y-m-d') == Carbon\Carbon::parse($post->created_at)->format('Y-m-d'))
<span>Today</span>
@else
{{ Carbon\Carbon::parse($post->created_at)->format('your_format') }}
@endif
one line;
{{ $post->created_at->isAfter(today()) ? 'Today' : $post->created_at->format('d-m-Y') }}
Please or to participate in this conversation.