【原创】Vue 时间过滤器

Vue.filter('dateFormat', function (originValue) {
  const dt = new Date(originValue);

  const y = dt.getFullYear();
  const m = (dt.getMonth() + 1 + '').padStart(2, '0');
  const d = (dt.getDate() + '').padStart(2, '0');

  const hh = (dt.getHours() + '').padStart(2, '0');
  const mm = (dt.getMinutes() + '').padStart(2, '0');
  const ss = (dt.getSeconds() + '').padStart(2, '0');

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
});
点赞

发表回复

电子邮件地址不会被公开。必填项已用 * 标注