use*_*026 2 javascript datetime calendar utc
我正在编写一个javascript代码来解析XML文件中的事件并将其插入到Google日历中.我将常规UTC日期转换为Google日历DateTime格式时遇到问题.
我的日期以此格式(UTC)显示:
Mon Apr 02 2013 15:14:33 GMT+0300 (Arab Standard Time)
Run Code Online (Sandbox Code Playgroud)
虽然我想转换的格式是(rfc 3999):
2013-1-16T10:00:00.000-07:00
Run Code Online (Sandbox Code Playgroud)
我尝试使用date.format()或getDateTime()等方法,但它从未起作用
任何帮助是极大的赞赏
请参阅生成类似于Google Tasks API的RFC 3339时间戳?:
/* use a function for the exact format desired... */
function ISODateString(d){
function pad(n){return n<10 ? '0'+n : n}
return d.getUTCFullYear()+'-'
+ pad(d.getUTCMonth()+1)+'-'
+ pad(d.getUTCDate())+'T'
+ pad(d.getUTCHours())+':'
+ pad(d.getUTCMinutes())+':'
+ pad(d.getUTCSeconds())+'Z'}
var d = new Date();
print(ISODateString(d)); // prints something like 2009-09-28T19:03:12Z
Run Code Online (Sandbox Code Playgroud)