ByteNote LogoByteNote

Navigation

  • Blog
  • 工具

    © 2025 ByteNote. All rights reserved.

    JS 时间格式化

    Oct 25, 202120 min read
        formateDate(date, rule) {
            let fmt = rule || 'yyyy-MM-dd hh:mm:ss'
            if (/(y+)/.test(fmt)) {
                fmt = fmt.replace(RegExp.$1, date.getFullYear())
            }
            const o = {
                // 'y+': date.getFullYear(),
                'M+': date.getMonth() + 1,
                'd+': date.getDate(),
                'h+': date.getHours(),
                'm+': date.getMinutes(),
                's+': date.getSeconds()
            }
            for (let k in o) {
                if (new RegExp(`(${k})`).test(fmt)) {
                    const val = o[k] + '';
                    fmt = fmt.replace(RegExp.$1, RegExp.$1.length == 1 ? val : ('00' + val).substr(val.length));
                }
            }
            return fmt;
        },
    

    相关文章

    Vite 配置文件注释

    Vite 配置文件 vite.config.js 提供了丰富的参数配置,用于优化开发和生产环境下的项目构建和运行。

    TS This comparison appears to be unintentional because the types

    比较联合类型 '"string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function"' 和数组类型 '"number[]"' 是无意义的,因为它们没有重叠。

    centos7 安装源问题设置网络后使用网上安装源

    在CentOS 7设置网络后,使用阿里云镜像源进行安装。

    什么是iSCSI存储阵列?

    iSCSI存储阵列是一种利用TCP/IP协议通过网络提供高可用性、可扩展性和可靠性的虚拟化存储解决方案,适用于企业级应用如数据库和虚拟化环境。

    Flutter 在已存在项目中添加 Mac desktop 支持

    在现有项目中通过运行特定命令为 Flutter 添加 Mac、Linux、Windows 和 Windows UWP 桌面平台支持。