最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

js 實(shí)現(xiàn)日期靈活格式化的小例子

 更新時(shí)間:2013年07月14日 15:28:02   作者:  
這篇文章介紹了js實(shí)現(xiàn)日期靈活格式化的小例子,有需要的朋友可以參考一下
復(fù)制代碼 代碼如下:

/**
 * 時(shí)間對(duì)象的格式化;
 */
Date.prototype.format = function(format) { 
    /*
     * eg:format="YYYY-MM-dd hh:mm:ss";
     */
    var o = { 
        "M+" :this.getMonth() + 1, // month 
        "d+" :this.getDate(), // day 
        "h+" :this.getHours(), // hour 
        "m+" :this.getMinutes(), // minute 
        "s+" :this.getSeconds(), // second 
        "q+" :Math.floor((this.getMonth() + 3) / 3), // quarter 
        "S" :this.getMilliseconds() 
    // millisecond 
    } 
    if (/(y+)/.test(format)) { 
        format = format.replace(RegExp.$1, (this.getFullYear() + "") 
                .substr(4 - RegExp.$1.length)); 
    } 
    for ( var k in o) { 
        if (new RegExp("(" + k + ")").test(format)) { 
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] 
                    : ("00" + o[k]).substr(("" + o[k]).length)); 
        } 
    } 
    return format; 
}

相關(guān)文章

最新評(píng)論

河津市| 精河县| 桑日县| 云龙县| 清徐县| 界首市| 桂阳县| 彭州市| 靖西县| 吉首市| 通城县| 庄河市| 通榆县| 清徐县| 巩留县| 越西县| 建始县| 铁力市| 四川省| 辽中县| 平昌县| 孙吴县| 蓬溪县| 永康市| 桃园县| 漳州市| 吉木萨尔县| 漳州市| 阿合奇县| 滨海县| 出国| 三门峡市| 佛坪县| 梅河口市| 成武县| 安阳县| 江永县| 武宁县| 东平县| 浙江省| 陈巴尔虎旗|