Date.prototype.getSeconds() returns the seconds for this date as an integer 0–59 in local time (MDN). It is read-only and does not change the Date.
Remember
date.getSeconds()
→ integer 0 … 59
→ NaN if the Date is invalid
Example (MDN-style):
new Date(1969, 6, 20, 0, 20, 18).getSeconds() → 18
getSeconds() → local seconds
getUTCSeconds() → UTC seconds
Syntax
Call date.getSeconds. Start with this line.
JavaScript
date.getSeconds()
Call
What it does
date.getSeconds()
Primary signature.
date.getSeconds(...)
Call with the arguments your case needs.
Built into JavaScript. Call getSeconds(...) on a Date instance — no import required.
Library declarations
JavaScript
date.getSeconds()
Parameters
This method has no parameters beyond those shown in the signature.
Return Value
Return Value
Description
*
The value returned by date.getSeconds().
JavaScript Examples
Example 1 — Read the Local Seconds
Call getSeconds() on fixed local date-times (MDN-style values).
Build local times. The sixth constructor argument is seconds.
Landing.00:20:18 → getSeconds() returns 18.
Night.23:15:30 → 30.
No mutation. The Date values are unchanged.
Example 2 — getSeconds() vs getUTCSeconds()
Local and UTC seconds can disagree near minute boundaries.
JavaScript
const d = new Date("1995-12-25T23:15:30Z"); // 23:15:30 UTC
console.log(d.getUTCSeconds()); // 30
console.log(d.getSeconds()); // local seconds (often 30, sometimes not)