一:格式化后的字符串---->date
eg:“2018-01-02”------>date类型
var str = "2019-01-09"
var dateStr = str.replace(/-/g,"/");
var resDate = new Date(dateStr);
二:date -----> 格式化字符串
eg:"20190101101010"----->2019-01-01 10:10:10
一:格式化后的字符串---->date
eg:“2018-01-02”------>date类型
var str = "2019-01-09"
var dateStr = str.replace(/-/g,"/");
var resDate = new Date(dateStr);
二:date -----> 格式化字符串
eg:"20190101101010"----->2019-01-01 10:10:10
转载于:https://www.cnblogs.com/adanxiaobo/p/8729438.html