Home JavaScript Date Methods getUTCSeconds() JavaScript Date getUTCSeconds() Method Definition Date.prototype.getUTCSeconds() returns the seconds of a date as an integer 0–59 according to universal time (UTC) . It is read-only and does not change the Date.
date.getUTCSeconds()
0 = start of the UTC minute
4 = MDN moon-landing sample
59 = last second of the UTC minute
→ integer 0 … 59
→ NaN if the Date is invalid
getUTCSeconds() → UTC seconds (0–59)
getSeconds() → local seconds (0–59) Syntax Call date.getUTCSeconds. Start with this line.
Call What it does date.getUTCSeconds()Primary signature. date.getUTCSeconds(...)Call with the arguments your case needs.
Built into JavaScript. Call getUTCSeconds(...) on a Date instance — no import required.
Library declarations Parameters Parameter Description Padding Optional. Use padStart(2, "0") for :04-style display
Return Value Return Value Description * The value returned by date.getUTCSeconds().
JavaScript Examples 1. MDN moon landing 2. Date.UTC values 3. vs getSeconds() Example 1 — MDN Moon Landing Instant Read UTC seconds from the classic Apollo 11 timestamp.
const moonLanding = new Date("July 20, 1969, 20:18:04 UTC");
console.log(moonLanding.getUTCSeconds()); // 4 How It Works Parse a UTC string. The UTC suffix pins the instant to universal time.Read the field. getUTCSeconds() returns the seconds part: 4.Range. Valid results stay in 0–59.Read-only. The call does not change moonLanding.Example 2 — Build with Date.UTC Construct UTC dates and read the second component at the edges.
const mid = new Date(Date.UTC(2026, 0, 1, 12, 0, 45));
const end = new Date(Date.UTC(2026, 0, 1, 12, 0, 59));
console.log(mid.getUTCSeconds()); // 45
console.log(end.getUTCSeconds()); // 59 How It Works Use Date.UTC. Arguments are year, month index, day, hour, minute, second (UTC).Wrap in new Date(...). That stores one absolute instant.Read seconds. getUTCSeconds() returns 45 and 59.Month index. January is 0 — same rule as the local constructor.Example 3 — getUTCSeconds() vs getSeconds() Both return 0–59, but one uses UTC fields and the other uses local fields.
const d = new Date(Date.UTC(2026, 0, 1, 12, 0, 45));
console.log(d.getUTCSeconds()); // 45
console.log(d.getSeconds()); // often 45 (offset is usually whole minutes)
console.log(typeof d.getUTCSeconds()); // "number" How It Works UTC getter. getUTCSeconds() always reads universal-time seconds.Local getter. getSeconds() follows the host timezone.Often equal. Offsets are usually whole minutes, so the second fields match.Pick one style. Prefer UTC getters in APIs and logs that must stay timezone-agnostic.Compatibility
Browser & Runtime Support Date.prototype.getUTCSeconds() is part of the language from early ECMAScript and is Baseline Widely available (MDN).
✓ Baseline · Widely available
Date.prototype.getUTCSeconds() Supported in every modern browser and Node.js. No polyfill needed for ordinary web apps.
99% Modern browser support
Google Chrome Supported · Desktop & Mobile
Full support
Mozilla Firefox Supported · Desktop & Mobile
Full support
Apple Safari Supported · macOS & iOS
Full support
Microsoft Edge Supported · Chromium
Full support
Internet Explorer No native support · Use a polyfill
Polyfill
Opera Supported · Modern versions
Full support
Samsung Internet Supported · Android
Full support
Bun Supported · JavaScript runtime
Supported
Deno Supported · JavaScript runtime
Supported
Node.js Supported · Server runtime
Supported
Android WebView Supported · Modern WebView
Full support Date.getUTCSeconds() Excellent
Bottom line: Safe everywhere. Focus on choosing UTC vs local getters correctly rather than feature detection.
Frequently Asked Questions What does Date.prototype.getUTCSeconds() return? An integer from 0 to 59 for the seconds within the current UTC minute. It is not total seconds since midnight or since 1970.
What is the difference between getUTCSeconds() and getSeconds()? getUTCSeconds() uses UTC calendar fields. getSeconds() uses local time. Prefer the UTC getter when your code is timezone-agnostic.
How is getUTCSeconds() different from getUTCMilliseconds()? getUTCSeconds() returns 0–59 for the UTC second. getUTCMilliseconds() returns 0–999 for the fraction inside that second.
What does getUTCSeconds() return on an invalid Date? NaN. Validate with Number.isNaN(date.getTime()) before using the result.
Can getUTCSeconds() return 60? No for valid dates—the range is 0–59. Overflow via setUTCSeconds carries into the next UTC minute.
Should I use getUTCSeconds() to measure elapsed time? No. Subtract getTime() values (or use Date.now()) and divide by 1000. The 0–59 field alone cannot measure intervals longer than one minute.
About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
11 people found this page helpful
Helpful Share Copy link Suggestion