I am trying to display the created_at
attribute using Carbon's diffForHumans()
in German in laravel 5.2.
created_at
is stored in the database as: 2017-03-29 17:31:52
The model
protected $dates = ['created_at', 'updated_at'];
public static function getCreatedAtAttribute($value)
{
Carbon::setLocale('de');
return Carbon::parse($value, 'Europe/Berlin')->diffForHumans();
}
dd($value);
returns "2017-03-29 17:31:52"
.
The view
@foreach($posts as $post)
<small></small>
@endforeach
The error
DateTime::__construct(): Failed to parse time string (vor 3 Tagen) at position 0 (v): The timezone could not be found in the database
I would be very thankful for any kind of help!
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire