JavaScript Date getUTCSeconds() Method

Beginner
5 min read
Updated: Nov 2026
3 examples
Date

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.

Remember
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.

JavaScript
date.getUTCSeconds()
CallWhat 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
JavaScript
date.getUTCSeconds()

Parameters

ParameterDescription
PaddingOptional. Use padStart(2, "0") for :04-style display

Return Value

Return ValueDescription
*The value returned by date.getUTCSeconds().

JavaScript Examples

Example 1 — MDN Moon Landing Instant

Read UTC seconds from the classic Apollo 11 timestamp.

JavaScript
const moonLanding = new Date("July 20, 1969, 20:18:04 UTC");

console.log(moonLanding.getUTCSeconds()); // 4
Try It Yourself

How It Works

  1. Parse a UTC string. The UTC suffix pins the instant to universal time.
  2. Read the field. getUTCSeconds() returns the seconds part: 4.
  3. Range. Valid results stay in 0–59.
  4. 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.

JavaScript
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
Try It Yourself

How It Works

  1. Use Date.UTC. Arguments are year, month index, day, hour, minute, second (UTC).
  2. Wrap in new Date(...). That stores one absolute instant.
  3. Read seconds. getUTCSeconds() returns 45 and 59.
  4. 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.

JavaScript
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"
Try It Yourself

How It Works

  1. UTC getter. getUTCSeconds() always reads universal-time seconds.
  2. Local getter. getSeconds() follows the host timezone.
  3. Often equal. Offsets are usually whole minutes, so the second fields match.
  4. Pick one style. Prefer UTC getters in APIs and logs that must stay timezone-agnostic.

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

An integer from 0 to 59 for the seconds within the current UTC minute. It is not total seconds since midnight or since 1970.
getUTCSeconds() uses UTC calendar fields. getSeconds() uses local time. Prefer the UTC getter when your code is timezone-agnostic.
getUTCSeconds() returns 0–59 for the UTC second. getUTCMilliseconds() returns 0–999 for the fraction inside that second.
NaN. Validate with Number.isNaN(date.getTime()) before using the result.
No for valid dates—the range is 0–59. Overflow via setUTCSeconds carries into the next UTC minute.
No. Subtract getTime() values (or use Date.now()) and divide by 1000. The 0–59 field alone cannot measure intervals longer than one minute.

Next: Date.now()

Learn how to read the current milliseconds since the Unix epoch.

Date.now() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

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