码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2017-04-22 12:53:09      阅读:1409      评论:0      收藏:0      [点我收藏+]

标签:console   span   pre   ons   var   get   let   color   ace   

 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     }

 

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

标签:console   span   pre   ons   var   get   let   color   ace   

原文地址:http://www.cnblogs.com/lijingran/p/6747166.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!