JavaScript时间戳格式化转换

  1. 时间戳转格式化日期

这里写图片描述


var time = new Date(时间戳);
alert( formatDate(time) );

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-100)+"-"+month+"-"+date+" "+hour+":"+minute+":"+;
 second},

你可能感兴趣的:(js)