English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

JavaScript getSeconds() method

 JavaScript Date Object

getSeconds()Returns the number of seconds (0-59)

getSeconds()The returned value is between59integer.

For minute information, seegetMinutes()Method.

For the hour number, seegetHours()Method.

Syntax:

date.getSeconds()
var d = new Date();
d.getSeconds();
Test and see‹/›

Browser compatibility

All browsers fully support the getSeconds() method:

Method
getSeconds()isisisisis

Technical details

Return value:to59an integer between
JavaScript version:ECMAScript 1

More Examples

Return the number of seconds for a specific date and time:

var d = new Date(#39;August 20, 1999 23:15:30');
d.getSeconds();
Test and see‹/›

Use the getHours(), getMinutes(), getSeconds(), and getMilliseconds() methods to display the time:

setInterval(function () {
   var date = new Date();
   var x = document.getElementById('result');
   x.innerHTML = date.getHours() + :" + date.getMinutes() + :" + date.getSeconds() + 
   ':' + date.getMilliseconds();
}, 1);
Test and see‹/›

 JavaScript Date Object