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 --- .../global_objects/date/tolocaletimestring/index.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'files/zh-cn/web/javascript/reference/global_objects/date/tolocaletimestring/index.html') diff --git a/files/zh-cn/web/javascript/reference/global_objects/date/tolocaletimestring/index.html b/files/zh-cn/web/javascript/reference/global_objects/date/tolocaletimestring/index.html index cf32bed733..f28a479d75 100644 --- a/files/zh-cn/web/javascript/reference/global_objects/date/tolocaletimestring/index.html +++ b/files/zh-cn/web/javascript/reference/global_objects/date/tolocaletimestring/index.html @@ -11,11 +11,11 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString -

语法

+

语法

dateObj.toLocaleTimeString([locales [, options]])
-

参数

+

参数

查看浏览器兼容性小节,看下哪些浏览器支持 locales 和 options 参数,还可以参看例子:检测 localesoptions 参数支持情况

@@ -23,9 +23,9 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString

The default value for each date-time component property is undefined, but if the hour, minute, second properties are all undefined, then hour, minute, and second are assumed to be "numeric".

-

例子

+

例子

-

例子:使用 toLocaleTimeString

+

例子:使用 toLocaleTimeString

没有指定语言环境(locale)时,返回一个使用默认语言环境和格式设置(options)的格式化字符串。

@@ -36,7 +36,7 @@ translation_of: Web/JavaScript/Reference/Global_Objects/Date/toLocaleTimeString alert(date.toLocaleTimeString()); // → "7:00:00 PM" if run in en-US locale with time zone America/Los_Angeles -

例子:检测 localesoptions 支持情况

+

例子:检测 localesoptions 支持情况

locales 和 options 参数不是所有的浏览器都支持。为了检测一种实现环境(implementation)是否支持它们,可以使用不合法的语言标签,如果实现环境支持该参数,则会抛出一个 RangeError 异常,反之会忽略参数。

@@ -50,7 +50,7 @@ alert(date.toLocaleTimeString()); } -

例子:使用 locales 参数

+

例子:使用 locales 参数

下例展示了本地化时间格式的一些变化。为了在应用的用户界面得到某种语言的时间格式,必须确保使用 locales 参数指定了该语言(可能还需要设置某些回退语言)。

@@ -81,7 +81,7 @@ alert(date.toLocaleTimeString(["ban", "id"])); // → "11.00.00" -

例子:使用 options 参数

+

例子:使用 options 参数

可以使用 options 参数来自定义 toLocaleTimeString 方法返回的字符串。

@@ -97,7 +97,7 @@ alert(date.toLocaleTimeString("en-US", {hour12: false})); // → "19:00:00" -

性能

+

性能

当格式化大量日期时,最好创建一个 Intl.DateTimeFormat 对象,然后使用该对象 format 属性提供的方法。

@@ -139,7 +139,7 @@ alert(date.toLocaleTimeString("en-US", {hour12: false}));

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

-

相关链接

+

相关链接