时间戳转换成时间js(年-月-日,例如“2017-04-22”)

时间:2024-08-05 13:06:08
  function GetDateByShiJianChuo(timespan) {
var date = new Date(parseInt(timespan.replace("/Date(", "").replace(")/", "")));
var dateStr = date.toLocaleDateString();
dateStr = dateStr.replace("/", "-").replace("/", "-");
return dateStr;
//console.log(date.toLocaleDateString());//2017/4/12
//console.log(date.toDateString());//Wed Apr 12 2017
//console.log(date.toLocaleString());//2017/4/12 上午12:00:00
//console.log(date.toLocaleTimeString());//上午12:00:00
}