时间格式的转换,时间戳转日期-年月日时分秒

//时间转换
dateLong2String(time) {
  var date = new Date(time);
  var year = date.getFullYear();
  var month = date.getMonth() + 1;
  var day = date.getDate();
  let h = date.getHours();
  h = h < 10 ? "0" + h : h;
  let m = date.getMinutes();
  m = m < 10 ? "0" + m : m;
  let s = date.getSeconds();
  s = s < 10 ? "0" + s : s;
  month = month < 10 ? "0" + month : month;
  day = day < 10 ? "0" + day : day;
  return year + "-" + month + "-" + day + " " + h + ":" + m + ":" + s;
},

  

posted @ 2017-05-03 10:29  guanqinghua  阅读(24)  评论(0编辑  收藏  举报