jeudi 20 août 2015

Handle datetime between php (Laravel API) and javascript (AngularJS)

I'm trying to make my Laravel API exchange dates with my Angularjs frontend.

It works for me from Laravel to JS by first converting my mysql datetime value using $newdate = Carbon::parse($event['date'])->toATOMString(); which outputs 2015-08-19T10:00:00+00:00 , then converting it later in javascript (Angularjs) by doing event.date = new Date(event.date); which outputs Date 2015-08-19T10:00:00.000Z.

My problem is posting my updated JS date objects back to PHP API to update the value in mysql (datetime). Carbon doesn’t like the date format he gets back:

2015-08-19T11:00:00.000Z

And I’m not sure how to handle this. I get the following error from my Laravel log: exception 'InvalidArgumentException' with message 'Trailing data' … Carbon/Carbon.php:392

How should I convert the above formatted date in php so Carbon accepts it? Thanks guys



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

Aucun commentaire:

Enregistrer un commentaire