慕容的工作随笔

慕容的工作随笔

记录学习和工作

【原创】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}`;
});

评论 (0)

还没有评论,来做第一个吧。

发表评论

提交后需管理员审核通过后显示