This article is in need of an editorial review.
This translation is incomplete. Please help translate this article from English.
概要
人間が読めるフォーマットのアメリカ英語でDateオブジェクトの時刻部分を返します。
構文
dateObj.toTimeString()
説明
Date インスタンスはは特定の日時を参照します。toString()をコールすると、人間が読めるフォーマットのアメリカ英語で日時を返します。SpiderMonkeyでは、これは日にちの部分 (day, month, and year) と時刻の部分 (hours, minutes, seconds, and time zone)から成ります。時々 時刻の部分の文字列を得ることは好ましいです。 そのようなことは、toTimeString() メソッドで出来ます。
toTimeString() メソッドは特に役に立ちます。というのは、ECMA-262 を満たすエンジンは Dateオブジェクトに対して、toString()から得る文字列と異なるからです。フォーマットは処理系依存で、アプローチを分割する単純な文字列は複数のエンジンを横断して一貫性のある結果を作らないかもしれません。
例
例: toTimeString()の基本的な使用
var d = new Date(1993, 6, 28, 14, 39, 7); console.log(d.toString()); // prints Wed Jul 28 1993 14:39:07 GMT-0600 (PDT) console.log(d.toTimeString()); // prints 14:39:07 GMT-0600 (PDT)
仕様
| 仕様 | ステータス | コメント |
|---|---|---|
| ECMAScript 3rd Edition. | Standard | Initial definition. |
| ECMAScript 5.1 (ECMA-262) The definition of 'Date.prototype.toTimeString' in that specification. |
Standard | |
| ECMAScript 6 (ECMA-262) The definition of 'Date.prototype.toTimeString' in that specification. |
勧告候補 |
ブラウザ実装状況
| 機能 | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|
| 基本サポート | (有) | (有) | (有) | (有) | (有) |
| 機能 | Android | Chrome for Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|---|
| 基本サポート | (有) | (有) | (有) | (有) | (有) | (有) |