我正在尝试使用以下网址在我的网站上显示 Google 日历
<a href="https://calendar.google.com/calendar/render?
action=TEMPLATE&
text={{ticket.subject}}&
dates=20170127T210000Z/20170127T220000Z&
details=For+details,+link+here:+https://www.example.com/&
location=Hyderabad,+Telangana,+India&sf=true&
output=xml#eventpage_6"
target="_blank" rel="nofollow">Add to calender</a>
正如您所观察到的,我已将日期值硬编码为 dates=20170127T210000Z/20170127T220000Z
,但我无法理解格式
20170127T210000Z = 2017 01 27 but what is T210000Z?
因为我需要使用下面的工单创建截止日期动态生成它
helpdesk_ticket.due_by = "2017-01-17T17:00:00-05:00"
最佳答案
这是标准Internet Date/Time Format遵循RFC3339协议(protocol)。
The following profile of ISO 8601 [ISO8601] dates SHOULD be used in new protocols on the Internet. This is specified using the syntax
description notation defined in [ABNF].date-time = full-date "T" full-time time-offset = "Z" / time-numoffset
您可以在 Calendar Events properties 中看到这些日期属性。 要将日期转换为 JS 中的 RFC339 日期时间格式,请使用 .toISOString() :
var today = new Date('05 October 2011 14:48 UTC');
console.log(today.toISOString()); // Returns 2011-10-05T14:48:00.000Z
关于javascript - 谷歌日历日期格式说明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41697206/