Javascript examples for Date:getHours
The getHours() method returns the hour from 0 to 23.
None
A Number, from 0 to 23, representing the hour
The following code shows how to return the hour, according to local time:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {//from w ww. j a v a 2s.co m var d = new Date("July 21, 2020 01:15:00"); var n = d.getHours(); document.getElementById("demo").innerHTML = n; } </script> </body> </html>