我正在尝试使用以下网址在我的网站上显示谷歌日历
<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"
答案 0 :(得分:0)
符合RFC3339协议的标准Internet Date/Time Format。
ISO 8601 [ISO8601]日期的以下简介应该用于 互联网上的新协议。这是使用语法
指定的 [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
答案 1 :(得分:0)
这是谷歌日历日期的原始格式:
dates=20170127T210000Z/20170127T220000Z
为了解释,我将把它转换为:
format='Ymd\\THi00\\Z+UTCTIME'
以上格式的意思是:
Y = years
m = month
d = day
T = make it as default dont change this. (Indicates the start of the time portion of the date time)
H = hours
i = minutes
00 = make it as default dont change this.
Z = make it as defaut dont change this. (Indicates the time zone is UTC)
+UTCTIME = your utc zone
这里有一个例子:
20220523T100000Z+07:00
这是一个例子的结果:
23 May 2022, 10.00am base on my utc in indonesia use +07:00