C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
JavaScript Date getHours() methodThe JavaScript date getHours() method returns the hour for the specified date on the basis of local time. SyntaxThe getHours() method is represented by the following syntax: dateObj.getHours() ReturnAn integer value between 0 and 23 that represents the hour. JavaScript Date getHours() method exampleHere, we will understand getHours() method through various examples. Example 1Let's see an example to print the value of current hour. <script> var hour=new Date(); document.writeln(hour.getHours()); </script> Output: 15 Example 2Let's see an example to print the value of hour from the given date. <script> var hour=new Date("August 15, 1947 20:22:10"); document.writeln(hour.getHours()); </script> Output: 20
Next TopicJavaScript Math
|