Easy Tutorial
❮ Prop Nav Online Dom Obj Date ❯

JavaScript setSeconds() Method

JavaScript Date Object

Example

Set the seconds field of the current time to 35:

d Output result:


Definition and Usage

The setSeconds() method is used to set the seconds field of a date object.

This method can also be used to set milliseconds.


Browser Support

All major browsers support the setSeconds() method.


Syntax

Parameter Values

Parameter Description
sec Required. Represents the seconds value. This value is an integer between 0 and 59: -1 is the last second of the previous minute<br>60 is the first second of the next minute
millisec Optional. Represents the milliseconds value. This value is between 0 and 999. Before ECMAScript standardization, this parameter was not supported: -1 is the last millisecond of the previous second<br>1000 is the first millisecond of the next second

Return Value

Type Description
Number The milliseconds representation of the adjusted date from January 1, 1970. Before ECMAScript standardization, this method returned nothing.

Technical Details

| JavaScript Version: | 1.0 | | --- | --- |


More Examples

Example

Set the seconds and milliseconds:

n Output result:


JavaScript Date Object

❮ Prop Nav Online Dom Obj Date ❯