mercredi 28 octobre 2015

Laravel 5 Carbon Unexpected data

I created new date field called start_date, and I also have two columns for created_at and updated_at which are defined as timestamp.

In my model I have following line, that should tell Laravel to treat these columns as Carbon objects.

protected $dates = ['created_at', 'updated_at', 'start_date'].

Request passes me date like this: 2015-10-28T10:37:31.337Z, and when I try to save it, I got following error:

InvalidArgumentException in Carbon.php line 414:
Unexpected data found.
Trailing data

in Carbon.php line 414
at Carbon::createFromFormat('Y-m-d H:i:s', '2015-10-28T10:37:31.337Z') in Model.php line 2925

I tried several things, including changing dateFormat on Model, changing format on property before saving model, but I keep receiving same error.

What is supposed way to handle situations like this? Can I have different types of columns handled by Carbon? Do I need to change it change format for them manually? I checked docs, but I couldn't find anything regarding that.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1kQR8LV
via IFTTT

Aucun commentaire:

Enregistrer un commentaire