2012-03-07 46 views
1

我有一个字符串Mar 7 2012将日期字符串转换为日期

如何将其转换为Date对象,所以我可以使用mydate.getDate()mydate.getMonth(),mydate.getFullYear()等?

+0

可能的重复http://stackoverflow.com/questions/476105/how-can-i-convert-string-to-datetime-with-format-specification-in-javascript – jbabey 2012-03-07 16:11:36

+0

可能的重复[如何在Javascript中将字符串转换为日期](http://stackoverflow.com/questions/2769901/how-to-turn-a-string-into-a-date-in-javascript) – 2012-03-07 16:12:07

回答

2

那么,它很简单

var d =new Date("March 7 2012"); 
document.write(d.getMonth()); //use it