publicFun.js 634 B

123456789101112131415
  1. export function formatTime(inputTime) {
  2. var date = new Date(inputTime);
  3.     var y = date.getFullYear();
  4.     var m = date.getMonth() + 1;
  5.     m = m < 10 ? ('0' + m) : m;
  6.     var d = date.getDate();
  7.     d = d < 10 ? ('0' + d) : d;
  8.     var h = date.getHours();
  9.     h = h < 10 ? ('0' + h) : h;
  10.     var minute = date.getMinutes();
  11.     var second = date.getSeconds();
  12.     minute = minute < 10 ? ('0' + minute) : minute;
  13.     second = second < 10 ? ('0' + second) : second;
  14. return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
  15. }