问题描述
我在。
我插入一个事件 {end:{dateTime:2016-10- 31T06:30:00Z},start:{dateTime:2016-10-31T06:00:00Z}}
并尝试过以下日期时间格式:
2016-10-31T06:00:00Z
2016-10-31T06:00:00-00:00
2016 -10-31T06:00:00 + 00:00
但无论输入格式如何,Google都会选择在设置日期时间时添加一小时。回应总是:
start:{
dateTime:2016-10-31T07:00 :00 + 01:00
我目前在斯德哥尔摩, +2小时抵消。我已经尝试设置单独的time_zone字段并省略单独的time_zone字段。
为什么会发生这种情况?而且,有没有什么正确的方法,或者我只需要在设置时间时考虑这个小时?
我建议您使用: {
end:{
dateTime:2016-10 -31T06:30:00,
timeZone:欧洲/斯德哥尔摩
},
开始:{
dateTime:2016-10-31T06 :00:00,
timeZone:Europe / Stockholm
}
}
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?
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"
}
}
这篇关于为什么Google API无论输入都设置了+01偏移量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!