The javascript Date.setMonth() method sets the specified date of each month according to local time.
Grammar
Date.setMonth(monthValue[, dayValue])
Note: Appearance and data within brackets are optional
Here are the details of the parameters:
If the dayValue parameter is not specified, the value returned from the getDate method is used. If the specified argument is outside the expected range, setMonth attempts to update the Date object's latest information accordingly. For example, if you use monthValue as 15, year will be incremented by 1 (year 1), and 3 will be used for the month value.
Return value:
Example:
<html> <head> <title>JavaScript setMonth Method</title> </head> <body> <script type="text/javascript"> var dt = new Date( "Aug 28, 2008 23:30:00" ); dt.setMonth( 2 ); document.write( dt ); </script> </body> </html>
This will produce the following results:
Fri Mar 28 23:30:00 UTC+0530 2008