一、日期转时间戳
function dateToUnix (dateString) {
// dateString = '2016年07月02日';
var d1 = dateString.split("年")[0],d2 = dateString.split("年")[1],
d3 = d2.split("月")[0],d4 = d2.split("月")[1];
var y = parseInt(d1),
m = parseInt(d3),
d = parseInt(d4);
var date = y+'/'+m+'/'+d,
unix = new Date(y, m-1,d),
timestamp = unix.getTime()/1000;
return timestamp;
}
二、时间戳转日期
function getLocalTime(secs)
{//时间戳转年/月/日
// var time = new Date(parseInt(secs) * 1000).toLocaleString();
var obj = new Date(parseInt(secs)*1000);
var year = obj.getFullYear(),
month = obj.getMonth()+1,
date = obj.getDate();
var time = year+"/"+month+"/"+date;
return time;
}