zoukankan      html  css  js  c++  java
  • 方法小工具整理

    /**
    *日期控件
    */
     1 Date.prototype.format = function (fmt) { //author: meizz
     2     var o = {
     3         "M+": this.getMonth() + 1, //月份
     4         "d+": this.getDate(), //
     5         "h+": this.getHours(), //小时
     6         "m+": this.getMinutes(), //
     7         "s+": this.getSeconds(), //
     8         "q+": Math.floor((this.getMonth() + 3) / 3), //季度
     9         "S": this.getMilliseconds() //毫秒
    10     };
    11     if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    12     for (var k in o)
    13         if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    14     return fmt;
    15 };
    16 
    17 function format(timestamp){
    18     return new Date(timestamp).format("yyyy-MM-dd")
    19 }
    20 
    21 function format2(timestamp){
    22     return new Date(timestamp).format("yyyy-MM-dd hh:mm:ss")
    23 }
    24 
    25 function dateNow() {
    26     return new Date().format("yyyy-MM-dd hh:mm:ss")
    27 }

    // js 获取 url 参数
     1 function getQueryVariable(variable)
     2 {
     3        var query = window.location.search.substring(1);
     4        var vars = query.split("&");
     5        for (var i=0;i<vars.length;i++) {
     6                var pair = vars[i].split("=");
     7                if(pair[0] == variable){return pair[1];}
     8        }
     9        return(false);
    10 }


    //去空格
    1 function trim(str) {
    2     return str.replace(/(^s*)|(s*$)/g, "");
    3 }


    //判断是否为空
    1 function isEmpty(s) {
    2     return s == null || s == undefined || s == 'undefined'
    3 }


    //判断字符串是否为空
    1 function isEmptyText(text) {
    2     return isEmpty(text) || text == ""
    3 }


    //随机数
    function random(start, end) {
        return Math.random() * (end - start) + start
    }
  • 相关阅读:
    Hbase shell 常用命令
    HTable基本概念
    通过HBase Shell与HBase交互
    把Nutch爬虫部署到Hadoop集群上
    wso2esb安装及helloworld
    nDPI 的论文阅读和机制解析
    Ubuntu 编译出现 ISO C++ 2011 不支持的解决办法
    404 Note Found 队-课堂实战-项目UML设计
    nDPI的安装与测试
    精读 SBAR SDN flow-Based monitoring and Application Recognition
  • 原文地址:https://www.cnblogs.com/weijiutao/p/11691227.html
Copyright © 2011-2022 走看看