时间戳转换成时间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     }

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM