I have the weirdest bug ever. I am talking to my API via angularjs and I try to update something by doing the following
console.log('updated: ', event.startsAt);
$http({
method: 'PUT',
url: baseurl + "/event/" + event.id,
data: {title: event.title, startsAt: moment(event.startsAt).clone().toDate(), entriesAllowed: event.entriesAllowed},
headers: {'Content-type': 'application/json'},
handleError: true
})
So the problem is in the event.startsAt variable. In the console log it give me the correct time:
Sat Dec 24 2016 16:15:00 GMT+0100 (CET)
but as soon as I send it and access it with my api it gives the same datetime but minus 1 hours so
Sat Dec 24 2016 15:15:00 GMT+0100 (CET)
Any idea what this could be? I use laravel for my api and I am getting the datetime with
$event->startsAt = Carbon::parse($request->get('startsAt'), 'Europe/Amsterdam');
Things I have tried myself
- Use momentJS to change datetime to a different format.
- adding/removing timezone in Laravel.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire