Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hii Friends,

I am using Date.js for date functionality.When i pass date in mm/dd/yyyy it automatically increament month by one.Please help me.

SessionDate = document.getElementById("txtdate_" + n).value.split("/");

var SDate = new Date(SessionDate[0], SessionDate[2], SessionDate[1] - 1);

In SDate Month automatically get increamented.

Thanks in advance
Posted

1 solution

Actually in javascript the month numbers strat from 0 to 11 so if you want the correct date then you should decrease the month by 1.

for example
var today = new Date(2014, 09, 26);
when you try to print the value of today it will give the result as
"Sun Oct 26 2014 00:00:00 GMT+0530 (India Standard Time)"
and if you change the above code to
var today = new Date(2014, 08, 26);
when you try to print the value of today it will give the result as
Fri Sep 26 2014 00:00:00 GMT+0530 (India Standard Time)

Hope I have understood your problem in a correct manner and the explanation helps.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900