/**
*日期控件
*/
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
}