JavaScript setUTCSeconds() Method
Example
Set the seconds field of the current time to 35 according to Universal Time (UTC):
var d = new Date();
d.setUTCSeconds(35);
d Output result:
Try it »
Definition and Usage
The setUTCSeconds() method is used to set the seconds field of a specified time according to universal time (UTC).
This method is used to set the seconds field of a specified time.
**Note:** Coordinated Universal Time, also known as Universal Time, Universal Standard Time, or International Coordinated Time, abbreviated as UTC.
**Note:** UTC time is the same as GMT (Greenwich) time.
Browser support





All major browsers support the setUTCSeconds() method.
Syntax
Date
.setUTCSeconds(
sec
,
millisec
)
Parameter Values
| Parameters | Description |
|---|---|
| sec |
Required. The value to set for the seconds field of dateObject. Expressed in universal time. This parameter is an integer between 0 and 59: |
Optional. The value to set for the milliseconds field of dateObject. Expressed in universal time.
This parameter is an integer between 0 and 999:
- -1 is the last millisecond of the previous second.
- 1000 is the first millisecond of the next second.
Return Value
| Type | Description |
|---|---|
| Number | The milliseconds representation of the adjusted date. |
Technical Details
| JavaScript version: | 1.3 |
|---|
More examples
Example
Set the seconds and milliseconds according to Universal Time (UTC):
var d = new Date();
d.setUTCSeconds(35,825);
var n=d.getUTCSeconds() + ":" + d.getUTCMilliseconds();
n Output result:
Try it »
JavaScript Date object