toUTCString() method converts a date to a string, interpreting it in the UTC time zone.
toGMTString() is an alias of this method.
A string representing the given date using the UTC time zone.
The value returned by
toUTCString() is a string in the form
Www, dd Mmm yyyy hh:mm:ss GMT, where:
||Day of week, as three letters (e.g.
||Day of month, as two digits with leading zero if required|
||Month, as three letters (e.g.
||Year, as four or more digits with leading zeroes if required|
||Hour, as two digits with leading zero if required|
||Minute, as two digits with leading zero if required|
||Seconds, as two digits with leading zero if required|
Date API was inspired by Java's
java.util.Date library (while the latter had become de facto legacy since Java 1.1 in 1997). In particular, the Java
Date class had a method called
toGMTString remains as an alias to
toUTCString, and they refer to the exact same function object. This means:
Date.prototype.toGMTString.name === "toUTCString";
const today = new Date("Wed, 14 Jun 2017 00:00:00 PDT"); const UTCstring = today.toUTCString(); // Wed, 14 Jun 2017 07:00:00 GMT
|ECMAScript Language Specification |
BCD tables only load in the browser