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

 1  function GetDateByShiJianChuo(timespan) {
 2         var date = new Date(parseInt(timespan.replace("/Date(", "").replace(")/", "")));
 3         var dateStr = date.toLocaleDateString();
 4         dateStr = dateStr.replace("/", "-").replace("/", "-");
 5         return dateStr;
 6         //console.log(date.toLocaleDateString());//2017/4/12
 7         //console.log(date.toDateString());//Wed Apr 12 2017
 8         //console.log(date.toLocaleString());//2017/4/12 上午12:00:00
 9         //console.log(date.toLocaleTimeString());//上午12:00:00
10     }

 

posted on 2017-04-22 10:56  lijingran  阅读(3100)  评论(0编辑  收藏  举报

导航