zoukankan      html  css  js  c++  java
  • JS相关

    Date的格式化扩展:

     Date.prototype.Format = function (f)
     {
         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(f)) f = f.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
         for (var k in o)
             if (new RegExp("(" + k + ")").test(f)) f = f.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
         return f;
     }
    
    //使用:
    var now = new Date().Format("yyyy-MM-dd");
    View Code

    获取URL中值:

    //获取URL中值
    function getQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
    
  • 相关阅读:
    Mayan游戏
    选择客栈
    Redundant Paths
    中心选址
    辗转相除
    字符串
    线段覆盖
    配置魔药
    宝库通道
    教官的监视
  • 原文地址:https://www.cnblogs.com/dances/p/7605781.html
Copyright © 2011-2022 走看看