Reputation: 804
I am trying to change the date format in laravel blade, I want to get 14 july 2017 but i am getting like 2017-07-14 06:04:08.Here is how i tried to retrive the created_date column.
{{ \App\Calllog::orderBy('created_at','desc')->where('jobseeker_id',$jobseeker->id)->pluck('created_at')->first() }}
Please guide me.
Upvotes: 0
Views: 17301
Reputation: 243
This will 100 percent solve your issue..
{{\App\Calllog::orderBy('created_at','desc')->where('jobseeker_id',$jobseeker->id)->first()->created_ar->format('jS F Y')}}
Upvotes: 0
Reputation: 2945
Laravel created_at is a Carbon instance, just check Carbon documentation to format the date as you want :
echo $created_at->format('j F Y');
// 14 july 2017
or if you're getting just a string parse it and then format it :
Carbon\Carbon::parse($created_at)->format('j F Y')
i think it should work like this :
{{ \App\Calllog::orderBy('created_at','desc')->where('jobseeker_id',$jobseeker->id)->first()->created_at->format('j F Y') }}
Upvotes: 4
Reputation: 133
use below code in your blade file
{{ date_format(date_create("your date variable"),'d M Y') }}
or if your date variable is already an date object then
{{ date_format($variable,'d M Y') }}
Upvotes: 0
Reputation: 9359
You can use Carbon for converting Date Time to your desired format.
<?php
$date = \Carbon\Carbon::parse($datetime)->format('dd-MM-yy');
?>
Now, use this $date
variable to display time like:
{{$date}}
See docs here.
Upvotes: 0