Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

JavaScript getSeconds() Method

JavaScript getSeconds() Method

Date Object Reference JavaScript Date object

Example

Return the seconds of a time based on local time:

var d = new Date();

var n = d.getSeconds();

n Output result:

Try it »


Definition and Usage

The getSeconds() method returns the seconds of a time. The return value is an integer between 0 and 59.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the getSeconds() method.


Syntax

Date

.getSeconds()

Return Value

Type Description
Number The return value is an integer between 0 and 59.

Technical Details

JavaScript version: 1.0

More examples

Display the current time
How to use getHours(), getMinutes(), and getSeconds() to display the current time.


Date Object Reference JavaScript Date object