I want to convert date to timestamp, my input is 26-02-2012. I used
26-02-2012
new Date(myDate).getTime();
It says NaN.. Can any one tell how to convert this?
Split the string into its parts and provide them directly to the Date constructor:
Update:
var myDate = "26-02-2012"; myDate = myDate.split("-"); var newDate = new Date( myDate[2], myDate[1] - 1, myDate[0]); console.log(newDate.getTime());
1.4m articles
1.4m replys
5 comments
57.0k users