I seem to be experiencing great difficulty working with Time only fields in Laravel. Nothing I seem to do will allow me to save the entry into the database and has now become frustrating.
I have setup my database schema as such:
...
$table->time( 'Interval_1_StartTime' )->nullable();
...
I have set my timezone accordingly in my app.php
:
'timezone' => 'Australia/Adelaide'
However, when I send the entry from my AngularJS application it looks like this (when outputting it to console):
Interval_1_StartTime: Thu Jan 01 1970 00:00:00 GMT+0930 (Australian Central Daylight Time)
And in Laravel (when I capture $request->Interval_1_StartTime
), I get returned both a different time that what I posted and an error stating the format is invalid.
data: "1969-12-31T14:30:00.000Z"
SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect time value: '1969-12-31T14:30:00.000Z' for column 'Interval_1_StartTime' at row 1
I have tried using Carbon::parse
, I have tried using $cast
to cast the value into specific format, I have even tried using $dates
to try and convert the value into a proper date. I have also tried formatting the value into a specific time format .format('H:m:s')
Nothing seems to work
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire