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

js实现将时间戳转换成2017-05-11 15:11:02

时间:2017-10-24 17:13:22      阅读:249      评论:0      收藏:0      [点我收藏+]

标签:bsp   eth   return   style   gets   console   func   min   date()   

function formatDate(now) { 
    var year=now.getYear(); 
    var month=now.getMonth()+1; 
    var date=now.getDate(); 
    var hour=now.getHours(); 
    var minute=now.getMinutes(); 
    var second=now.getSeconds(); 
    return "20"+year+"-"+month+"-"+date+" "+hour+":"+minute+":"+second; 
} 

      
var d=new Date(1508833784588);//时间戳
console.log(formatDate(d));//

 

js实现将时间戳转换成2017-05-11 15:11:02

标签:bsp   eth   return   style   gets   console   func   min   date()   

原文地址:http://www.cnblogs.com/rockyan/p/7724353.html

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