I am using the daterangepicker component of jquery. The Date.parse() function of jquery gives some weird output when i pass the date as "Jan 2011". Here's the sample output for different use cases:
Code snippet:
var dateStr = "Jan 2011";
var dt = Date.parse(dateStr);
alert(dt.getDate() + "/" + dt.getMonth());
Output :
dateStr = "Jan 2011" : output = 25/0 (todays date is 25 feb 2011)
dateStr = "Feb 2011" : output = 1/1
dateStr = "Dec 2011" : output = 1/11
So for any other month that Jan, the date is set to 1st date of the month, whereas only for jan the date is set to the current date.
Any idea what could be the reason for this?
It's not standart
Date.parsefunction in you example.Standart
parsefunction returns numeric result, not Date object.Javascript parse() Method
In you example
parsefunction returns Date object.function
Date.parsewas redefined in you code. Please check it.Standart
parsefunction always returns first day in month in your case