From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/date/toutcstring/index.html | 110 +++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 files/ja/web/javascript/reference/global_objects/date/toutcstring/index.html (limited to 'files/ja/web/javascript/reference/global_objects/date/toutcstring') diff --git a/files/ja/web/javascript/reference/global_objects/date/toutcstring/index.html b/files/ja/web/javascript/reference/global_objects/date/toutcstring/index.html new file mode 100644 index 0000000000..38d3f67926 --- /dev/null +++ b/files/ja/web/javascript/reference/global_objects/date/toutcstring/index.html @@ -0,0 +1,110 @@ +--- +title: Date.prototype.toUTCString() +slug: Web/JavaScript/Reference/Global_Objects/Date/toUTCString +tags: + - Date + - JavaScript + - Method + - Prototype + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Date/toUTCString +--- +
{{JSRef}}
+ +

toUTCString() メソッドは、協定世界時 (UTC) のタイムゾーンに基づき、日付を文字列へ変換します。

+ +

rfc7231ecma-262 toUTCString の改訂に基づき、 2021 版では負の数が可能になります。

+ +
{{EmbedInteractiveExample("pages/js/date-toutcstring.html","shorter")}}
+ + + +

構文

+ +
dateObj.toUTCString()
+ +

返値

+ +

UTC タイムゾーンに基づき、与えられた日付を表す文字列。

+ +

解説

+ +

toUTCString() から返される文字列は、 Www, dd Mmm yyyy hh:mm:ss GMT の形の文字列です。

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
書式文字列説明
Www曜日、3文字で表す (例 Sun, Mon, ...)
dd日、必要に応じて先頭に0が付いた2桁の数字で表す
Mmm月、3文字で表す (例 Jan, Feb, ...)
yyyy年、必要に応じて先頭に0が付いた4桁以上の数字で表す
hh時、必要に応じて先頭に0が付いた2桁の数字で表す
mm分、必要に応じて先頭に0が付いた2桁の数字で表す
ss秒、必要に応じて先頭に0が付いた2桁の数字で表す
+ +

ECMAScript 2018 以前では、返値の書式はプラットフォームによって様々です。もっとも一般的な返値は RFC-1123 形式の日付であり、これは RFC-822 形式の日付をわずかに改訂したものでした。

+ +

+ +

toUTCString() を使う

+ +
let today = new Date('Wed, 14 Jun 2017 00:00:00 PDT');
+let UTCstring = today.toUTCString(); // Wed, 14 Jun 2017 07:00:00 GMT
+
+ +

仕様書

+ + + + + + + + + + + + +
仕様書
{{SpecName('ESDraft', '#sec-date.prototype.toutcstring', 'Date.prototype.toUTCString')}}
+ +

ブラウザーの互換性

+ + + +

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

+ +

関連情報

+ + -- cgit v1.2.3-54-g00ecf