microsoft-graph-apimicrosoft-graph-calendar

Timezone issues when scheduling a meeting using microsoft-graph


When I schedule a new meeting using Microsoft Graph Explorer, I get the wrong time.

If I call https://graph.microsoft.com/v1.0/me/mailboxsettings, I get my Time Zone: "timeZone": "W. Europe Standard Time".

If I then call https://graph.microsoft.com/v1.0/me/events with the payload:

{
  "subject": "My event W. Europe Standard Time 3",
  "start": {
    "dateTime": "2019-04-02T16:01:03.353Z",
    "timeZone": "W. Europe Standard Time"
  },
  "end": {
    "dateTime": "2019-04-02T16:47:03.353Z",
    "timeZone": "W. Europe Standard Time"
  }
}

I get the scheduled meeting in my Outlook as expected, but the time is incorrect. The time I get in Outlook is 18:10 to 18:47.


Solution

  • When you put a Z at the end of the time, you're saying the time is UTC. You need to remove the time zone information from the time in order for it to get treated as a local time:

    {
      "subject": "My event W. Europe Standard Time 3",
      "start": {
        "dateTime": "2019-04-02T16:01:00",
        "timeZone": "W. Europe Standard Time"
      },
      "end": {
        "dateTime": "2019-04-02T16:47:00",
        "timeZone": "W. Europe Standard Time"
      }
    }