getUTCSeconds() returns the second component (0–59) from a Date object in UTC. This guide covers syntax, five examples, comparisons with local getters, and safe UTC time patterns.
01
Syntax
date.getUTCSeconds()
02
Range
0 – 59
03
UTC
Not local
04
vs getSeconds
Can differ
05
Format
HH:MM:SS UTC
06
Validate
Invalid → NaN
Fundamentals
Introduction
Server logs, API timestamps, and global cron rules often reference UTC clocks. The JavaScript Date object stores one instant internally; getUTCSeconds() reads the second hand of the UTC clock—not total seconds elapsed since midnight or since 1970.
If you need seconds for a user-facing local clock, use getSeconds(). Use getUTCSeconds() when your scheduling or display follows UTC boundaries.
Concept
Understanding the getUTCSeconds() Method
Date.prototype.getUTCSeconds() is a zero-argument instance method. It never mutates the original Date—it only reads the UTC second component as an integer from 0 to 59.
Pair it with getUTCHours(), getUTCMinutes(), and getUTCMilliseconds() to assemble UTC time parts, or use toISOString() when a full UTC string is enough.
💡
Beginner Tip
For elapsed duration between two instants, subtract getTime() values and divide by 1000—do not subtract getUTCSeconds() alone.
Foundation
📝 Syntax
JavaScript
dateObj.getUTCSeconds()
Parameters
None.
Return value
Integer 0–59 for a valid date in UTC.
NaN if dateObj is an invalid Date.
Cheat Sheet
⚡ Quick Reference
Goal
Code
Current UTC seconds
new Date().getUTCSeconds()
Seconds from UTC parts
new Date(Date.UTC(2026, 6, 4, 14, 30, 45)).getUTCSeconds() → 45
Local seconds
date.getSeconds()
Pad to two digits
String(date.getUTCSeconds()).padStart(2, "0")
Elapsed seconds
(end.getTime() - start.getTime()) / 1000
Valid date check
!Number.isNaN(date.getTime())
Compare
📋 getUTCSeconds() vs Similar Methods
UTC getters mirror local getters. Pick the one that matches where your data is displayed or stored.
getUTCSeconds()
0–59
UTC seconds
getSeconds()
local
Local seconds
getUTCMinutes()
0–59
UTC minutes
getTime()
epoch ms
Full instant
Hands-On
Examples Gallery
Open DevTools Console (F12) or use Try-it links. Fixed UTC times use Date.UTC or ISO strings ending in Z for predictable results.
📚 Getting Started
Read the current UTC second component from a new Date.
Example 1 — Get the Current UTC Seconds
Call getUTCSeconds() on the current instant.
JavaScript
const now = new Date();
const utcSeconds = now.getUTCSeconds();
console.log("UTC seconds:", utcSeconds);
At 20:45:30 UTC on June 15, it is 02:16:00 on June 16 in UTC+5:30. getUTCSeconds() stays 30; getSeconds() becomes 0. Use UTC getters when cron rules follow UTC.
Applications
🚀 Common Use Cases
UTC cron jobs — trigger at second 0 of each UTC minute.
Log timestamps — show UTC HH:MM:SS in debug panels.
API rate windows — bucket requests by UTC second for short intervals.
Manual formatting — build UTC clocks with getters.
Test fixtures — assert second parts from Date.UTC.
Countdown displays — derive remaining time from getTime(), not getter subtraction.
🧠 How getUTCSeconds() Resolves the Second
1
Internal instant
The Date stores milliseconds since Unix epoch (UTC).
Storage
2
UTC projection
Engine reads UTC time fields, including the current minute.
UTC
3
Extract second
Second within that UTC minute (0–59) is returned.
getUTCSeconds
4
🌐
Format or schedule
Pad for clocks or pair with UTC minute checks.
Important
📝 Notes
getUTCSeconds() is UTC; use getSeconds() for local UI clocks.
Returns 0–59 only—not total seconds since midnight.
For elapsed duration, use (end.getTime() - start.getTime()) / 1000.
Invalid dates propagate NaN—validate with Number.isNaN(date.getTime()).
Pad with padStart(2, "0") for two-digit second displays.
For full UTC strings, toISOString() is often simpler than manual getters.
Compatibility
Browser & Runtime Support
Date.prototype.getUTCSeconds() has been available since the first JavaScript Date implementation (ES1). It works in every browser and Node.js.
✓ Baseline · ES1
Date.prototype.getUTCSeconds()
Supported in Chrome, Firefox, Safari, Edge, Internet Explorer, and all Node.js versions. No polyfill required.
99%Universal API
Google ChromeSupported · Desktop & Mobile
Full support
Mozilla FirefoxSupported · Desktop & Mobile
Full support
Apple SafariSupported · macOS & iOS
Full support
Microsoft EdgeSupported · Chromium
Full support
Internet ExplorerNo native support · Use a polyfill
Polyfill
OperaSupported · Modern versions
Full support
Samsung InternetSupported · Android
Full support
BunSupported · JavaScript runtime
Supported
DenoSupported · JavaScript runtime
Supported
Node.jsSupported · Server runtime
Supported
Android WebViewSupported · Modern WebView
Full support
Date.getUTCSeconds()Excellent
Bottom line: Safe everywhere. Pair UTC getters together and use getTime() for elapsed second calculations.
Wrap Up
Conclusion
getUTCSeconds() reads the second component (0–59) from a JavaScript Date in UTC. Use it for UTC clocks and scheduling; use local getters or locale formatters when showing time to end users.
Next, learn Date.now() for the current timestamp in milliseconds, or review getSeconds() for local second reads.