Encodera

Thanks for reading!

Donate to the site — we work hard for you.

JavaScript reference

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:

42

Notes

Milliseconds come from a separate method, getMilliseconds().

See also

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.

Thanks for reading!

Donate to the site — we work hard for you.