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

today.setMonth(today.getMonth() - 1);
document.write("1 Month Before: "+today);
Output  
Today: Sat Nov 29 2014 11:54:48 GMT+0530 (India Standard Time)
1 Month Before: Wed Oct 29 2014 11:54:48 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