Date.prototype.getSeconds()
Returns the seconds of a date in local time.
Syntax
date.getSeconds()
Returns
number — The seconds, 0 through 59.
Examples
const d = new Date("2026-05-15T14:07:42");
console.log(d.getSeconds());
Output
42
const d = new Date("2026-05-15T14:07:00");
console.log(d.getSeconds());
Output
0
Notes
- Always in the range 0-59.
- Use `getMilliseconds()` for the fractional part and
`getUTCSeconds()` for UTC.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |
| node | 0.10 |