Date.Parse()的时区问题

timezone issue with Date.Parse()

本文关键字:时区 问题 Parse Date      更新时间:2023-09-26

我的脚本中有以下一段代码:

Date.parse('10/01/2010 01:01:01')

运行脚本后得到的结果如下:

September 30, 2010 22:01:01

这可能是一个问题与日期。parse()或我做错了什么?

这不是问题:这是功能:

parse方法接受一个日期字符串(例如"Dec 25,1995 ")并返回自UTC时间1970年1月1日00:00:00以来的毫秒数。本地时区用于解释不包含时区信息的参数。[…如果未指定时区,则假定为本地时区。

…所以这里有:

的区别
Date.parse("Thu, 01 Jan 1970 00:00:00");
// ... returns 14400000 in timezone GMT-0400, and other values in other 
// timezones, since there is no time zone specifier in the argument.

…和…

Date.parse("Thu, 01 Jan 1970 00:00:00 GMT-0400");
// ... returns 14400000 no matter the local time zone.