CodesJava

Easy learning with example program codes

JavaScript setHours() method

The JavaScript date setHours() method sets the hour value for the particular date on the basis of local time.

Syntax:

dateObj.setHours(new_Hours);

Parameters:
new_Hours: Integer value between 0 to 23.

Example:

<!DOCTYPE html>
<html>
<body>
<script>   	 
var bday =new Date("November 16, 1994 21:00:10");  
document.writeln(bday.getHours() + "<br>");  
bday.setHours(12);  
document.writeln(bday.getHours());  
</script>  
</body>
</html>

Output:

21
12
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status