ivva
ivva

Reputation: 2949

Laravel 4 timestamp format

I'm using Laravel 4 and I want to display created_at. It is timestamp. I display it in this way - it should be in this format -Y.m.d / h:i

but it shows wrong result. Column created_at in database has value -

2016-05-18 00:00:00

but when I display it in this way it shows:

2016.05.18 / 12:00

@if($data->created_at !== '0000-00-00 00:00:00') 
{{date('Y.m.d / h:i', strtotime($data->created_at)) }}
@endif

Upvotes: 0

Views: 273

Answers (1)

Zamrony P. Juhara
Zamrony P. Juhara

Reputation: 5262

Y-m-d H:i:s is ISO format to store date time value and Laravel is always using it AFAIK. But it should not be problem if you are using Eloquent then created_at is Carbon datetime and you can format it by calling format() method. {{ $data->created_at->format('Y.m.d / H:i'); }}

Upvotes: 1

Related Questions