vue.js格式化时间并每秒更新

公用过滤器页面


//在月份、日期、小时等小于10前面补0
let padDate = function (value) {
  return value <10 ? '0' + value:value;
};

let formatDateTime = value => {
  var date = new Date(value);
  var year = date.getFullYear();
  var month = padDate(date.getMonth()+1);
  var day = padDate(date.getDate());
  var hours = padDate(date.getHours());
  var minutes = padDate(date.getMinutes());
  var seconds = padDate(date.getSeconds());
  console.log(1111111111111111111111)
  return year + '-' + month + '-' + day + '-' + ' ' + hours + ':' + minutes + ':' + seconds;
}

 

页面 




 

你可能感兴趣的:(vue,vue)