JavaScript Date setSeconds() Method
- Previous Page setMonth()
- Next Page setTime()
- Go Back to the Previous Level JavaScript Date Reference Manual
Definition and Usage
setSeconds()
Method to set the seconds of the date object.
This method can also be used to set milliseconds.
Instance
Example 1
Set the seconds to 35:
var d = new Date(); d.setSeconds(35);
Example 2
Set Seconds and Milliseconds:
var d = new Date(); d.setSeconds(35, 825); var n = d.getSeconds() + ":" + d.getMilliseconds();
Syntax
Date.setSeconds(sec, millisec)
Parameter Value
Parameter | Description |
---|---|
sec |
Required. Represents the integer of seconds. Expected value is 0-59, but other values are allowed:
|
millisec |
Optional. Represents the integer of milliseconds. Expected value is 0-999, but other values are allowed:
|
Technical Details
Return Value: | A number representing the milliseconds between the date object and midnight of January 1, 1970. |
---|---|
JavaScript Version: | ECMAScript 1 |
Browser Support
Method | Chrome | IE | Firefox | Safari | Opera |
---|---|---|---|---|---|
setSeconds() | Support | Support | Support | Support | Support |
Related Pages
Tutorial:JavaScript Date
Tutorial:JavaScript Date Format
Tutorial:JavaScript Date Setting Methods
- Previous Page setMonth()
- Next Page setTime()
- Go Back to the Previous Level JavaScript Date Reference Manual