YouTip LogoYouTip

Jsref Setutchours

# JavaScript setUTCHours() Method [![Image 8: Date Object Reference Manual](#) JavaScript Date Object](#) ## Example Set the hour field to 15 according to Coordinated Universal Time (UTC): var d = new Date(); d.setUTCHours(15); _d_ outputs according to local time: Thu Jun 18 2026 15:14:48 GMT+0000 (Coordinated Universal Time) [Try it yourself Β»](#) * * * ## Definition and Usage The setUTCHours() method is used to set the hour (0 - 23) according to Coordinated Universal Time (UTC). This method can also be used to set the minutes, seconds, and milliseconds. **Tip:** Coordinated Universal Time, also known as Universal Time, World Standard Time, International Coordinated Time, abbreviated as UTC (Universal Coordinated Time). **Note:** UTC time is the same as GMT (Greenwich Mean Time). * * * ## Browser Support ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) The setUTCHours() method is supported by all major browsers. * * * ## Syntax _Date_.setUTCHours(_hour_,_min_,_sec_,_millisec_) ## Parameter Values | Parameter | Description | | :--- | :--- | | _hour_ | Required. The value to set the hour field of the dateObject to. This parameter is an integer between 0 and 23: * -1 is the last hour of the previous day. * 24 is the first hour of the next day | | _min_ | Optional. The value to set the minute field of the date Object to. This parameter is an integer between 0 and 59: * -1 is the last minute of the previous hour * 60 is the first minute of the next hour | | _sec_ | Optional. The value to set the second field of the date Object to. This parameter is an integer between 0 and 59: * -1 is the last second of the previous minute * 60 is the first second of the next minute | | _millisec_ | Optional. The value to set the millisecond field of the date Object to. This parameter is an integer between 1 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 number of milliseconds from January 1, 1970 to the adjusted date. | ## Technical Details | JavaScript Version: | 1.3 | | --- | * * * ## More Examples ## Example Set the time to 15:35:01 according to Coordinated Universal Time (UTC): var d = new Date(); d.setUTCHours(15,35,1); _d_ outputs the result according to local time: Thu Jun 18 2026 15:35:01 GMT+0000 (Coordinated Universal Time) [Try it yourself Β»](#) ## Example Set the time to 48 hours ago according to Coordinated Universal Time (UTC): var d = new Date(); d.setUTCHours(d.getUTCHours()-48); _d_ outputs the result according to local time: Tue Jun 16 2026 03:14:48 GMT+0000 (Coordinated Universal Time)
← Jsref SetutcmillisecondsJsref Setutcfullyear β†’