2016-11-01 32 views
0

我轉換DateObject串date.getTime()的做

var date = new Date(); //Tue Nov 01 2016 17:00:48 GMT-0400 (EDT) 
    var string = date.toString(); //Tue Nov 01 2016 17:00:48 GMT-0400 (EDT) 

現在我想給我的字符串轉換爲日期我object.How可以做到這一點的反向?

var dateObject = ?????? 

回答

0

日期很容易轉換。作爲一個字符串:

var date = new Date(); 
var dateStr = date.toString(); 
var dateObject = new Date(dateStr); 

數字:

var dateNum = date*1; 
dateObject = new Date(dateNum); 
+0

謝謝! @cuniculis –