JavaScript getSeconds() Method
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





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.
JavaScript Date object