zoukankan      html  css  js  c++  java
  • js 格式化时间

     写一个过滤器

    getTime(item) {
          const date = new Date(
         //这一步是根据我后端返回的时间格式处理的,可选用  item.replace(
    /-/g, "/").substring(0, item.indexOf(".")) ); const Y = date.getFullYear() + "-"; const M = (date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1) + "-"; const D = (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " "; const h = (date.getHours() < 10 ? "0" + date.getHours() : date.getHours()) + ":"; const m = (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + ":"; const s = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds(); return Y + M + D + h + m + s; }

    拿走不谢,我是金陵彭于晏我们下期再见!!!

  • 相关阅读:
    寒假学习进度7
    寒假学习进度3
    寒假学习进度6
    寒假学习进度5
    寒假学习进度8
    加分项
    每日博客
    每日博客
    每日博客
    每日博客
  • 原文地址:https://www.cnblogs.com/lq2333/p/13218399.html
Copyright © 2011-2022 走看看