Reputation: 9693
I am using Laravel 5.6, PHP 7.2.10
2018-12-24 12:42:00.0 is getting converted to "Dec 24 2018, 12:12 pm"
Output of tinker
$dt = App\Video::find(8611)->created_at;
=> Illuminate\Support\Carbon @1545655320 {#3075
date: 2018-12-24 12:42:00.0 UTC (+00:00),
}
>>> Carbon\Carbon::parse($dt)->format('M d Y, h:m a')
=> "Dec 24 2018, 12:12 pm"
>>>
what I am missing or doing wrong or this is any known behavior of carbon.
Upvotes: 0
Views: 1865
Reputation: 1536
Instead of
format('M d Y, h:m a')
try
format('Y-m-d H:i:s.u')
Upvotes: 1
Reputation: 67
Hope help you:
Carbon\Carbon::parse($dt, 'YYYY-MM-DD HH:mm:ss')->format('M d Y, h:m a')
Upvotes: 0