首页 > Web开发 > 详细

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

时间:2017-04-22 12:16:44      阅读:823      评论:0      收藏:0      [点我收藏+]
 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”)

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!