C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Date getUTCHours() methodThe JavaScript date getUTCHours() method returns the hour for the specified date on the basis of universal time. SyntaxThe getUTCHours()method is represented by the following syntax: dateObj.getUTCHours() ReturnAn integer value between 0 and 23 that represents the hour. JavaScript Date getUTCHours() method exampleHere, we will understand getUTCHours() method through various examples. Example 1Let's see an example to print the value of current hour according to universal time. <script> var hour=new Date(); document.writeln("Hour value : "+hour.getUTCHours()); </script> Output: Hour value : 12 Example 2Let's see an example to print the value of hour from the given date according to universal time. <script> var hour1=new Date("August 15 1975 22:15:30 GMT+11:00"); var hour2=new Date("August 15 1975 22:15:30 GMT-11:00"); document.writeln("Hour value1 : "+hour1.getUTCHours()+"<br>"); document.writeln("Hour value2 : "+hour2.getUTCHours()); </script> Output: Hour value1 : 11 Hour value2 : 9
Next TopicJavaScript Date
|