JavaScript getSeconds()Method

Date 对象参考手册JavaScript Date Object

Examples

Return the seconds of the time according to local time:

var d = new Date();
var n = d.getSeconds();

nOutput:


Try it Yourself »

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


实例s

More Examples

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


Date 对象参考手册JavaScript Date Object

Other Extensions