Example 1 — Format a UTC Instant
Convert a parsed date into an RFC 7231 UTC string.
const event = new Date("14 Jun 2017 00:00:00 PDT");
console.log(event.toUTCString());
// "Wed, 14 Jun 2017 07:00:00 GMT" How It Works
- Parse an input.
"14 Jun 2017 00:00:00 PDT"is midnight in Pacific Daylight Time. - Convert to UTC. PDT is UTC−7, so midnight PDT is 07:00 UTC.
- Format.
toUTCString()prints weekday, date, time, andGMT. - Stable timezone. Unlike
toString(), the result does not depend on your local offset.

