Published Jun 22, 2021Updated Jun 5, 2023
Contribute to Docs

Called from an instance of the Date class, will return the seconds according to the local time.



The return value of getSeconds() will only be an integer number between 0 and 59, meaning seconds.


To determine if the match has ended or still ongoing:

const today = new Date('June 25, 2021 13:41:50');
if (today.getSeconds() > 50) {
console.log('The match has ended.');
} else {
console.log('This match is still ongoing.');
// Output: This match is still ongoing.

Codebyte Example

The example below defines a new Date object dateTimeNow, and then saves the result of the getSeconds() method in a new variable seconds. Finally, the current date\time, the current seconds, and the seconds remaining in the current minute are logged to the console.


All contributors

Looking to contribute?

Learn JavaScript on Codecademy