I have a string Mar 7 2012.
How do I convert this to a Date object, so I can use mydate.getDate(), mydate.getMonth(), mydate.getFullYear() etc?
I have a string Mar 7 2012.
How do I convert this to a Date object, so I can use mydate.getDate(), mydate.getMonth(), mydate.getFullYear() etc?
Well, Its pretty simple
var d =new Date("March 7 2012");
document.write(d.getMonth()); //use it
I'd use Date.parse in conjunction with Date#setTime. For example:
var d = new Date();
d.setTime(Date.parse("Mar 7 2012"));
You've pretty good reference docs in mozilla's dev. network: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date