日期转时间戳:
var newDate=parseInt(new Date().getTime().toString());
var strDate = '2018-03-30 11:47:12';
//字符串转日期格式,strDate要转为日期格式的字符串
function getDate(strDate){
var date = eval('new Date(' + strDate.replace(/\d+(?=-[^-]+$)/,
function (a) { return parseInt(a, 10) - 1; }).match(/\d+/g) + ')');
return date;
}
//时间戳转日期格式
var handleDate =1522315759934
function getYYYYmmssdate(handleDate) { var now = new Date(handleDate), y = now.getFullYear(), m = now.getMonth() + 1, d = now.getDate(); return y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d) + " " + now.toTimeString().substr(0, 8); }