Latest web development tutorials

JavaScript setUTCSeconds () method

Date Object Reference JavaScript Date Object

Examples

According to Universal Time (UTC) in seconds of the current time field is set to 35:

var d = new Date();
d.setUTCSeconds(35);

d output:


try it"

Definition and Usage

setUTCSeconds () method is used according to Universal Time (UTC) setting specifies the time in seconds field.

This method is suitable for a specified time to set the seconds field.

Tip: Coordinated Universal Time, also known as the unified world time, Universal Time, Coordinated Universal Time, abbreviated UTC.

Note: UTC time and GMT (Greenwich Mean) time the same.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support setUTCSeconds () method.


grammar

Date.setUTCSeconds( sec , millisec )

Parameter Values

parameter description
sec

Required. DateObject give the value of the seconds field. It indicates the use of the world.

This parameter is an integer from 0 to 59:

  • -1 Is the last second minute
  • For the first 60 seconds of the next minute
millisec

Optional. Millisecond value field to give dateObject settings. It indicates the use of the world.

This parameter is an integer from 0 to 999:

  • -1 On a last-second 1 ms
  • 1000 for the next second in the first millisecond

return value

Type 描述
Number 调整过的日期的毫秒表示。

technical details

JavaScript version: 1.3


More examples

Examples

According to Universal Time (UTC) to set the number of seconds and milliseconds:

var d = new Date();
d.setUTCSeconds(35,825);
var n=d.getUTCSeconds() + ":" + d.getUTCMilliseconds();

n output:


try it"


Date Object Reference JavaScript Date Object