JavaScript setSeconds () method
Examples
The current time in seconds field to 35:
var d = new Date();
d.setSeconds(35);
d.setSeconds(35);
d output:
try it"
Definition and Usage
The setSeconds () method is used to set the target date of the seconds field.
This method can be used to set the number of milliseconds.
Browser Support
All major browsers support setSeconds () method.
grammar
Date.setSeconds( sec , millisec )
Parameter Value
参数 | 描述 |
---|---|
sec | 必需。表示秒的数值。
该值是介于 0 ~ 59 之间的整数:
|
millisec | 可选。表示毫秒的数值。
介于 0 ~ 999 之间。在 EMCAScript 标准化之前,不支持该参数:
|
return value
Type | 描述 |
---|---|
Number | 1970年1月1日至调整过的日期的毫秒表示。在 ECMAScript 标准化之前,该方法什么都不返回。 |
technical details
JavaScript version: | 1.0 |
---|
More examples
Examples
Set the number of seconds and milliseconds:
var d = new Date();
d.setSeconds(35,825);
var n=d.getSeconds() + ":" + d.getMilliseconds();
d.setSeconds(35,825);
var n=d.getSeconds() + ":" + d.getMilliseconds();
n output:
try it"