zoukankan      html  css  js  c++  java
  • jquery日期格式化

    function dateFormat(date, format){

        date = new Date();
        var map = {
            "YY": date.getYear(),
            "M": date.getMonth() + 1//月份
            "d": date.getDate(), //
            "h": date.getHours(), //小时
            "m": date.getMinutes(), //
            "s": date.getSeconds(), //秒  
            "q": Math.floor((date.getMonth() + 3) / 3), //季度
            "S": date.getMilliseconds() //毫秒
        };

        format = format.replace(/([YMdhmsqS])+/g, function(all, t){
            var v = map[t];
            if (v !== undefined) {
                if (all.length > 1) {
                    v = "0" + v;
                    v = v.substr(v.length - 2);
                }
                return v;
            }
            else if (t === "Y") {
                return (date.getFullYear() + "").substr(4 - all.length);
            }
            return all;
        });
        return format;
    }
     

     var nowdate = dateFormat(Date(),'YYYY-MM-dd');

    alert(nowdate);
     
  • 相关阅读:
    02-05 flutter provider的使用
    02-04 flutter 构造函数总结
    02-03 flutter异步
    02-02dart语法
    02-01dart语法
    01-01 iOS内存对齐、内存对齐算法
    01-02 iOS kvo、kvc
    01-03 category 原理概述
    多线程编程 (2) -NSOperation
    IOS基本控件属性
  • 原文地址:https://www.cnblogs.com/qhorse/p/4670883.html
Copyright © 2011-2022 走看看