SQL PHP HTML ASP JavaScript articles and free scripts to download
JavaScript Date

setMonth()

We can fix the month and day part of date object by using setmonth JavaScript function. We can set the month from 0 to 11. In this January month is taken as 0 month and December is taken as 11.

dateobject.setMonth(month,day)

Sample code is here

<script type="text/javascript">
var dt= new Date();
document.write(dt + "<br><br>");
dt.setMonth(3,5);
document.write(dt);
</script>

The output of above code

Try to change the month beyond 11 and see how the year part also change. Change this like this.

dt.setMonth(12,5);

The output is here


Google+

More on JavaScript Date & Time
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked




Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer