JavaScript UTC Date Methods and Time Zones

JavaScript provides a parallel set of UTC methods for reading a Date without applying the host's local time-zone offset. Use them when your calculation or data exchange is explicitly based on Coordinated Universal Time.

const date = new Date("2026-09-10T12:00:00Z");
console.log(date.getUTCHours()); // 12
console.log(date.toUTCString());

The same Date can produce different local components depending on the environment, while its UTC components refer to the same instant.

Local Date Methods vs UTC Methods Top ↑

const now = new Date();
console.log(now.getHours());
console.log(now.getUTCHours());

getHours() uses local time. getUTCHours() uses UTC.

UTC Getter Methods Top ↑

UTC methodRange / meaning
getUTCFullYear()Full UTC year.
getUTCMonth()0–11.
getUTCDate()1–31.
getUTCDay()0 Sunday through 6 Saturday.
getUTCHours()0–23.
getUTCMinutes()0–59.
getUTCSeconds()0–59.
getUTCMilliseconds()0–999.
const date = new Date("2026-09-10T12:34:56.789Z");
console.log(date.getUTCFullYear());
console.log(date.getUTCMonth());
console.log(date.getUTCDate());
console.log(date.getUTCHours());

getTimezoneOffset() Top ↑

getTimezoneOffset() returns the difference, in minutes, between the Date interpreted as UTC and as local time. The sign can feel reversed: local zones ahead of UTC return a negative value.

const offsetMinutes = new Date().getTimezoneOffset();
console.log(offsetMinutes);

The result reflects the host environment and the represented date. In regions with daylight-saving changes, the value can vary across the year.

Convert a Date with toUTCString() Top ↑

const date = new Date();
console.log(date.toUTCString());

toUTCString() is useful for a readable UTC representation. For machine-oriented ISO output, prefer toISOString().

Create a UTC Timestamp with Date.UTC() Top ↑

const timestamp = Date.UTC(2026, 8, 10, 12, 0, 0);
const date = new Date(timestamp);

Date.UTC() uses zero-based month numbers, just like the numeric Date constructor, but interprets the components as UTC.

UTC Output with toISOString() Top ↑

const iso = new Date().toISOString();
console.log(iso);

The returned string is UTC and ends in Z.

Display a Named Time Zone Top ↑

UTC methods do not convert a Date into arbitrary named zones such as Asia/Kolkata or America/New_York. Use locale formatting with a timeZone option.

const text = new Date().toLocaleString("en-IN", {
  timeZone: "Asia/Kolkata",
  dateStyle: "medium",
  timeStyle: "medium"
});

Offsets Can Change with Daylight Saving Time Top ↑

Do not assume one fixed offset represents a named time zone for all dates. Some zones change offset because of daylight-saving rules or historical changes. Named-zone formatting lets the runtime apply the appropriate rule for the represented instant.

Common UTC and Time-Zone Mistakes Top ↑

  • Treating UTC and GMT as interchangeable in every technical context.
  • Assuming getTimezoneOffset() returns the offset written in the input string; it reflects the host's local zone.
  • Manually adding a fixed offset for a named zone that observes DST.
  • Mixing local getters and UTC getters in the same date calculation without a reason.
  • Forgetting that the Date object's numeric timestamp itself represents the instant independently of display zone.

Date Reference




Subscribe to our YouTube Channel here



plus2net.com










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer