I am building an event calendar app, and I am a bit unsure about how this will output for different timezones.
- User create an event, select start and end date + time
- The event is displayed in a calendar on selected date and time.
This is how I format the datetime for display in calendar:
Data how it is stored / retrieved from DB:
var startDate = '2014-03-09 12:00:00.000';
var endDate = '2014-03-09 17:00:00.000';
Format of date before output to calendar (basicly how far I have gotten on this):
var start = new Date(startDate.replace(' ', 'T'));
var end = new Date(endDate.replace(' ', 'T'));
console.log('start: ' + start);
console.log('end: ' + end);
Console Log:
start: Sun Mar 09 2014 12:00:00 GMT+0100 (UTC)
end: Sun Mar 09 2014 17:00:00 GMT+0100 (UTC)
This approach is working just fine, for my timezone, however, I am not sure how this will work for another timezone, example in USA?
The event will start march 9, 12:00 , and if my approach for another timezone will "change" the start/end time based on user timezone, for the calendars event list, this will not be good.
So my question is, will my approach work across timezones, or will it need more work to accomplish what I am looking for? Any and all suggestions are appreciated :)