• JS 自定义样式格式化日期


    Date.prototype.format = function (fmt) {
                var o = {
                    "M+": this.getMonth() + 1,                 //月份
                    "d+": this.getDate(),                    //日
                    "h+": this.getHours(),                   //小时
                    "m+": this.getMinutes(),                 //分
                    "s+": this.getSeconds(),                 //秒
                    "q+": Math.floor((this.getMonth() + 3) / 3), //季度
                    "S": this.getMilliseconds()             //毫秒
                };

                if (/(y+)/.test(fmt)) {
                    fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
                }

                for (var k in o) {
                    if (new RegExp("(" + k + ")").test(fmt)) {
                        fmt = fmt.replace(
                            RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
                    }
                }

                return fmt;
            }
  • 相关阅读:
    ubuntu18【合上盖子不休眠】
    linux和windows双系统开机显示 Minimal BASHlike line editingis supported xxxxxx
    Linux下opera不支持h5播放器的解决方法
    linux openjdk路径
    Linux安装redis tar.gz
    dpkg 安装deb文件
    Linux破解Navicat15
    kali设置grub主题
    kali安装git tar.gz
    kali 安装 teamviewer 显示检测到wayland
  • 原文地址:https://www.cnblogs.com/refuge/p/12040403.html
Copyright © 2020-2023  润新知