js时间与时间戳互相转换

var _time1 = Date.parse(new Date(‘2017-05-02 00:00:00’))/1000;
  //将设定的日期转换为时间戳  
_time1 = getLocalTime(_time1+86400);
//时间戳转换为时间格式

function getLocalTime(nS) {
    return new Date(parseInt(nS) * 1000).toLocaleString().replace(/年|月/g, "-").replace(/日/g, " ");
}
原文地址:https://www.cnblogs.com/DreamerLeaf/p/7520591.html