Date.prototype.getSeconds
Returns the seconds.
Available since: ES1
Syntax
date.getSeconds()Return value
numberThe seconds from 0 to 59.
Examples
The seconds of a date:
console.log(new Date(2026, 2, 15, 9, 5, 42).getSeconds());Output:
42Notes
Milliseconds come from a separate method, getMilliseconds().
See also
- Date.prototype.getMinutes — Returns the minutes.
- Date.prototype.getTime — Returns the date as a number of milliseconds.
In the tutorial
- Dates and time — The Date object in JavaScript: creating a date, reading the year, month and day, changing a date, the difference between dates and the ISO format.