• js 格式化时间


    export const formatTime = (time) => {
      if (!time) {
        return '';
      }
      const y = time.substr(0, 4);
      const m = time.substr(4, 2);
      const d = time.substr(6, 2);
      return `${y}-${m}-${d}`;
    };
    // 格式化时间
    
    
    export const getYYMMDD = () => {
      const time = new Date();
      const y = time.getFullYear();
      let m = time.getMonth() + 1;
      let d = time.getDate();
      const h = time.getHours();
      m = m < 10 ? `0${m}` : m;
      d = d < 10 ? `0${d}` : d;
      return `${y}-${m}-${d}`;
    };
    // 获取当前时间并格式化
    export const getNowTime = () => {
      const time = new Date();
      const y = time.getFullYear();
      let m = time.getMonth() + 1;
      let d = time.getDate();
      let h = time.getHours();
      let mi = time.getMinutes();
      let s = time.getSeconds();
      m = m < 10 ? `0${m}` : m;
      d = d < 10 ? `0${d}` : d;
      h = h < 10 ? `0${h}` : h;
      mi = mi < 10 ? `0${mi}` : mi;
      s = s < 10 ? `0${s}` : s;
      return `${y}-${m}-${d} ${h}:${mi}:${s}`;
    };
  • 相关阅读:
    重要:VC DLL编程
    VC++程序员如何做好界面
    复习二叉搜索树作的几道题
    eclipse JAVA反编译
    秒,毫秒,微秒,纳秒,皮秒,飞秒
    redis实现tomcat集群session共享
    redis启用持久化
    Spring
    Spring scope
    FastJSON 使用
  • 原文地址:https://www.cnblogs.com/arealy/p/14215043.html
Copyright © 2020-2023  润新知