VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-date-setutchours-method/

⇱ JavaScript Date setUTCHours() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Date setUTCHours() Method

Last Updated : 11 Jul, 2025

The date.setUTCHours() method is used to set hours into a date object according to universal time which is created using the Date() constructor.
Syntax: 

DateObj.setUTCHours(hours_Value);

Parameter: This method accepts a single parameter as mentioned above and described below: 

  • hours_Value: This parameter holds the value of hour which is used to set in the date object created using the date() constructor.

Return Values: It returns the new i.e. updated hour which is set by the setUTCHours() method.

Note: The DateObj is a valid Date object created using the Date() constructor in which we want to set the hours.
More codes for the above method are as follows:

Below are examples of Date.setUTCHours() method. 

Example 1: 

Output: 

11

Example 2: If in the Date() constructor we do not give hours while creating the Date object, still setUTCHours() method will be able to set new hour according to the universal time which is given as its parameter in the created Date object. 

Output: 

11

Example 3: If nothing as a parameter is given in the Date() constructor, still the setUTCHours() method will be able to set hour but a month, year, and date remain current ones according to universal time. 
Here 11 is the new hour, 2 is the current month i.e March, 30 is the current date and 2018 is the current year. 

Output:  

11
2
30
2018

Example 4: If the value of an hour as 26 is given as the parameter of the setHours() method, It will set 2 as the hour because the hour range is from 0 to 23, and hence, here 24 is subtracted because 0 to 23 is 24. 

Output: 

2
9
14
1996

We have a complete list of Javascript Date Objects, to check those please go through this article.

Supported Browsers: The browsers supported by the JavaScript Date setUTCHours() method are listed below:

  • Google Chrome
  • Internet Explorer
  • Mozilla Firefox
  • Opera
  • Safari

We have a Cheat Sheet on Javascript where we covered all the important topics of Javascript to check those please go through .

Comment