Knowledge Walls
Laya
Hyderabad, Andhra Pradesh, India
Date.prototype.setHours() Method in Date Class of Javascript Syntax with Examples
2024 Views
Usage 
The setHours() method is used to sets the hours for mentioned date based on local time.
Syntax 
dateObj.setHours(hoursValue)
Example
var today = new Date();
document.write("Today: "+today);
document.write("<br />");

today.setHours(today.getHours() - 1);
document.write("1 Hour Before: "+today);
Output 
Today: Sat Nov 29 2014 12:27:42 GMT+0530 (India Standard Time)
1 Hour Before: Sat Nov 29 2014 11:27:42 GMT+0530 (India Standard Time)
 
Best Lessons of "Javascript Syntax with Examples"
Top lessons which are viewed more times.
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details