JavaScript setUTCHours () method
Examples
According to Universal Time (UTC) field to set the hours of 15:
d.setUTCHours(15);
d output in local time:
try it"
Definition and Usage
setUTCHours () method is used according to Universal Time (UTC) to set the hour (0--23).
This method can be used to set the number of minutes, seconds and millimeters.
Tip: Coordinated Universal Time, also known as the unified world time, Universal Time, Coordinated Universal Time, abbreviated UTC (Universal Coordinated Time).
Note: UTC time is GMT (Greenwich Mean) time.
Browser Support
All major browsers support setUTCHours () method.
grammar
Parameter Values
参数 | 描述 |
---|---|
hour | 必需。要给 dateObject 设置的小时字段的值。
该参数是 0 ~ 23 之间的整数:
|
min | 可选。要给 date Object 设置的分钟字段的值。
该参数是 0 ~ 59 之间的整数:
|
sec | 可选。要给 date Object 设置的秒字段的值。
该参数是 0 ~ 59 之间的整数:
|
millisec | 可选。要给 date Object 设置的毫秒字段的值。
该参数是 1 ~ 999 之间的整数:
|
return value
Type | description |
---|---|
Number | The number of milliseconds January 1, 1970 to the adjusted date. |
technical details
JavaScript version: | 1.3 |
---|
More examples
Examples
According to Universal Time (UTC) Set the time to 15:35:01:
d.setUTCHours(15,35,1);
d in local output:
try it"
Examples
According to Universal Time (UTC) Set the time was 48 hours ago:
d.setUTCHours(d.getUTCHours()-48);
d in local output:
try it"