我在时区得到奇怪结果时遇到问题。
我正在一个全新的日历上测试一个小代码。我在 2012 年 11 月 7 日 22:00 到 23:00 进行了测试活动。
function myFunction() {
Logger.clear();
var calendar=CalendarApp.getCalendarById("foo@group.calendar.google.com");
var now=new Date();
Logger.log(calendar.getTimeZone());
Logger.log(Session.getTimeZone());
Logger.log(now.toISOString());
Logger.log(now.toUTCString());
Logger.log(calendar.getEventsForDay(now)[0].getStartTime());
}
这就是我在 11 月 7 日 00:29 运行它的结果
Europe/Rome
Europe/Rome
2012-11-06T23:28:25.889Z
Tue, 06 Nov 2012 23:28:25 GMT
Wed Nov 07 13:00:00 PST 2012
我读了一篇旧博客文章http://googleappsscript.blogspot.it/2011/03/demystifying-time-zones-in-apps-script_21.html但它对我没有帮助。
如何在日历的时区(或脚本的时区)中获取开始日期?