Reputation: 3611
I'm using the angular-bootstrap-calendar and my event list has this format:
{"events":[{"eventid":"7","title":"Events","type":"info","startsAt":"2015-09-24T10:00:00+00:00","endsAt":"2015-09-24T11:00:00+00:00","draggable":"true","resizable":"true"}]}
But when my events are displayed in the calendar, it shows 6am instead of 10am.
I'm guessing it has to do the Carbon conversion of my dates?
$startAt = Carbon::parse($appointments['appointment_start'])->toATOMString();
or the conversion of my dates to Javascript Date Objects and timezones
$http.get('../api/events').success(function(events) {
// Convert dates to Javascript Date Object
for (var i = 0; i < events.events.length; i++) {
events.events[i].startsAt = new Date(events.events[i].startsAt);
events.events[i].endsAt = new Date(events.events[i].endsAt);
}
Not sure how I should handle this? I guess my event dates (i.e 2015-09-24T10:00:00+00:00 ) should have a different format?
Upvotes: 2
Views: 7180
Reputation: 3611
Found the solution.
Needed to add the timezone in there:
$startAt = Carbon::parse($appointments['appointment_start'], \Auth::user()->timezone)->toATOMString();
In your case, the timzone can be set with a variable ($timezone)
$startAt = Carbon::parse($appointments['appointment_start'], $timezone)->toATOMString();
or hardcoded ('Europe/London') :
$startAt = Carbon::parse($appointments['appointment_start'], 'Europe/London')->toATOMString();
Upvotes: 3