问题
I'm using Google's API Explorer for their Calendar API on this page.
I am inserting an event { "end": { "dateTime": "2016-10-31T06:30:00Z" }, "start": { "dateTime": "2016-10-31T06:00:00Z" } }
and have tried the following datetime formats:
2016-10-31T06:00:00Z
2016-10-31T06:00:00-00:00
2016-10-31T06:00:00+00:00
But no matter input format, Google chooses to add an hour when setting the datetime. The response is always:
"start": {
"dateTime": "2016-10-31T07:00:00+01:00"
}
I'm currently in Stockholm, which has +2 hours offset. I've tried both setting the separate time_zone field and omitting the separate time_zone field.
Why is this happening? And, is there any "right way" or do I simply need to take this added hour into account when setting time?
回答1:
I suggest to use the timeZone property to specify the time zone properly.
Sample request using the "timeZone":
"Europe/Stockholm":
{
"end": {
"dateTime": "2016-10-31T06:30:00",
"timeZone": "Europe/Stockholm"
},
"start": {
"dateTime": "2016-10-31T06:00:00",
"timeZone": "Europe/Stockholm"
}
}
来源:https://stackoverflow.com/questions/40213713/why-does-google-api-set-01-offset-no-matter-input