From c40612041809fe289aba58aefa170bbe784aba1f Mon Sep 17 00:00:00 2001 From: t7yang Date: Mon, 10 Jan 2022 08:38:07 +0800 Subject: remove name attribute for zh-CN --- .../reference/global_objects/date/parse/index.html | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html') diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html index 5b0a6cf01d..eef2f86594 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/parse/index.html @@ -18,7 +18,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse -

语法

+

语法

显式调用:

@@ -29,7 +29,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse
new Date(dateString).getTime()
 
-

参数

+

参数

dateString
@@ -42,7 +42,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse
一个表示从1970-1-1 00:00:00 UTC到给定日期字符串所表示时间的毫秒数的数值。如果参数不能解析为一个有效的日期,则返回{{jsxref("NaN")}}。
-

描述

+

描述

parse 方法接受一个日期字符串(例如 "Dec 25, 1995"),并返回从1970-1-1 00:00:00 UTC到该日期字符串所表示日期的毫秒数。该方法在基于字符串值设置日期值时很有用,例如结合使用{{jsxref("Global_Objects/Date/setTime", "setTime()")}} 方法和 {{jsxref("Global_Objects/Date", "Date()")}} 构造函数。

@@ -60,7 +60,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/parse

由于 parse() 是 {{jsxref("Date")}} 的一个静态方法 , 所以应该使用 Date.parse() 来调用,而不是作为 {{jsxref("Date")}} 的实例方法。

-

默认时区的区别

+

默认时区的区别

当输入为 "March 7, 2014" 时, parse()  将默认使用本地时区。但如果使用 ISO  格式如 "2014-03-07" ,则会被默认为 UTC (ES5 和 ECMAScript 2015) 时区。  因此除非系统本地时区为 UTC,由这些字符串解析出的 {{jsxref("Date")}}  对象可能会因为 ECMAScript  版本不同而代表不同的时间。这意味着两个看起来等效的字符串可能因为它们的格式不同而被转换成不同的值。

@@ -91,9 +91,9 @@ new Date('2014-25-23').toISOString(); Date.parse('foo-bar 2014'); // 返回: NaN -

例子

+

例子

-

例子:使用 Date.parse()

+

例子:使用 Date.parse()

如果 IPOdate 是一个已经存在的 {{jsxref("Date")}} 对象,则可以把其设置为本地时间 1995年8月9日。如下:

@@ -169,11 +169,11 @@ Date.parse('foo-bar 2014');

{{Compat("javascript.builtins.Date.parse")}}

-

兼容性提示

+

兼容性提示

Firefox 49 {{geckoRelease(49)}} 修改了解析2位数年份的方式,从和 Internet Explorer 一致改为和 Google Chrome  浏览器一致。现在,2位数的年份小于等于 50  的将会被解析为21世纪的年份。比如, 04/16/17 ,在之前会被解析为 1917年4月16日,现在将被解析为 2017年4月16日。为了避免任何可能的同步问题或者有歧义的年份,推荐使用 ISO 8601 格式如 "2017-04-16" ({{bug(1265136)}})。

-

相关链接

+

相关链接