Click here to Skip to main content
15,881,882 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I know it is ideal practice to store event start & end datetime values in the database table by converting from local time to UTC time. And then while displaying it on the calendar convert it back to the local time or user prefered timezone.

But I can't understand why is Google storing timezone name for start & end datetime in the below code

var event = {
  'summary': 'Google I/O 2015',
  'location': '800 Howard St., San Francisco, CA 94103',
  'description': 'A chance to hear more about Google\'s developer products.',
  'start': {
    'dateTime': '2015-05-28T09:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'end': {
    'dateTime': '2015-05-28T17:00:00-07:00',
    'timeZone': 'America/Los_Angeles'
  },
  'recurrence': [
    'RRULE:FREQ=DAILY;COUNT=2'
  ],
  'attendees': [
    {'email': 'lpage@example.com'},
    {'email': 'sbrin@example.com'}
  ],
  'reminders': {
    'useDefault': false,
    'overrides': [
      {'method': 'email', 'minutes': 24 * 60},
      {'method': 'popup', 'minutes': 10}
    ]
  }
};

var request = gapi.client.calendar.events.insert({
  'calendarId': 'primary',
  'resource': event
});

request.execute(function(event) {
  appendPre('Event created: ' + event.htmlLink);
});


What I have tried:

I am trying to create a simple alarm app with timezone support. I am storing datetime values in the DB table by converting them from local time to UTC
Posted
Updated 21-Jun-18 21:03pm

1 solution

Consider an event running from 10 March to 12 March, with daylight saving time going into effect on 11 March. In that case the time zone at the start of a Los Angeles event would be PST (Pacific Standard Time) and at the end it would be PDT (Pacific Daylight Time).
 
Share this answer
 
v2
Comments
Christopher Fernandes 22-Jun-18 3:46am    
So it is used to indicate that the event was created in a specific timezone before converting to UTC
[no name] 22-Jun-18 3:57am    
In your example, the start and end time are not in UTC, but in PST. The event is from 9am to 5pm in GMT-7. The timeZone string is just a friendlier representation of GMT-7.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900