vendredi 29 mai 2020

casts datetime format in Laravel

As the Laravel document, we can cast the value to DateTime.

https://laravel.com/docs/5.8/eloquent-serialization#date-serialization

protected $casts = [
    'birthday' => 'date:Y-m-d',
    'joined_at' => 'datetime:Y-m-d H:00',
];

There result is :

"2020-05-29 00:00:00" but i want to result like that:

"2020-10-29T00:00"

I can use Carbon with format "Y-m-d\TH:i");

if possible to format like "2020-10-29T00:00" if I don't use the Carbon?

any ideas will be appreciated.




Aucun commentaire:

Enregistrer un commentaire