zoukankan      html  css  js  c++  java
  • time

    /**
     * 时间对象的格式化;
     
    */
     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;
     }
  • 相关阅读:
    P1939 【模板】矩阵加速(数列)
    NUMBER BASE CONVERSION POJ
    Raid POJ
    Genius ACM HihoCoder
    BZOJ1500: [NOI2005]维修数列 Splay维护序列
    BZOJ3245: 最快路线 拆点dijkstra
    存个头
    895E
    894E
    tarjan缩点/求桥模板
  • 原文地址:https://www.cnblogs.com/sniper007/p/2218152.html
Copyright © 2011-2022 走看看