javascript - 谷歌日历日期格式说明

标签 javascript jquery calendar google-calendar-api freshdesk

我正在尝试使用以下网址在我的网站上显示 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/

相关文章:

javascript - 将组件名称从 HTML 传递到组件

带有 async=true 的 JQuery .ajax 总是返回错误

java - 如何从字符串中获取经过的年数

javascript - 将表示毫秒的字符串转换为日期

java - 为什么 GregorianCalendar.getTimeInMillis() 和 GregorianCalendargetTimeInMillis(1970.01.01) 之间存在差异

java - java(Android)中通过日历函数获取负值

javascript - 使用 webpack 将 react 和 react-router 导出到独立的 html 文件时,应用程序不运行

php - 如何使用 php 或 javascript 编写一个函数来确定 16 位整数的人口数?

javascript - 如何根据值过滤对象的属性?

javascript - 将 jquery 条件为 (':checked' ) 转换为 bool 数组