Date.prototype.toUTCString()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

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

rfc7231ECMA-262 toUTCString の改訂に基づくと、負の数が可能です。

試してみましょう

const event = new Date("14 Jun 2017 00:00:00 PDT");

console.log(event.toUTCString());
// Expected output: "Wed, 14 Jun 2017 07:00:00 GMT"

構文

js
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 桁の数字で表す

toUTCString() の使用

js
const today = new Date("Wed, 14 Jun 2017 00:00:00 PDT");
const UTCstring = today.toUTCString(); // Wed, 14 Jun 2017 07:00:00 GMT

仕様書

Specification
ECMAScript® 2025 Language Specification
# sec-date.prototype.toutcstring

ブラウザーの互換性

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
toUTCString

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

関連情報