Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Date.prototype.toTimeString()

这篇翻译不完整。请帮忙从英语翻译这篇文章

概述

toTimeString() 方法以人类易读形式返回一个日期对象时间部分的字符串,该字符串以美式英语格式化。

语法

dateObj.toTimeString()

描述

Date 对象的实例引用一个具体的时间点。 调用 toString 方法以美式英语和人类易读的形式,返回日期对象的格式化字符串。在 SpiderMonkey 里,该字符串由日期部分(年月日)和其后的时间部分(时分秒和时区)组成。有时会需要获取时间部分的字符串,这可以由 toTimeString 方法完成。

The toTimeString method is especially useful because compliant engines implementing ECMA-262 may differ in the string obtained from toString for Date objects, as the format is implementation-dependent; simple string slicing approaches may not produce consistent results across multiple engines.

例子

例子:toTimeString 方法的简单使用

var d = new Date(1993, 6, 28, 14, 39, 7);

println(d.toString());     // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT)
println(d.toTimeString()); // prints 14:39:07 GMT-0600 (PDT)

规范

规范版本 规范状态 注解
ECMAScript 3rd Edition Standard Initial definition.
ECMAScript 5.1 (ECMA-262)
Date.prototype.toTimeString
Standard  
ECMAScript 6 (ECMA-262)
Date.prototype.toTimeString
Release Candidate  

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (Yes) (Yes) (Yes) (Yes) (Yes)
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (Yes) (Yes) (Yes) (Yes) (Yes) (Yes)

相关链接

文档标签和贡献者

 此页面的贡献者: teoli, AlexChao
 最后编辑者: teoli,