Date.prototype.format = function (style) {
/// <summary>格式化日期</summary>
/// <param name="name" type="string">格式:例yyyy-MM-dd</param>
/// <returns type="Date">返回日期</returns>
var o = {
"Y+": this.getFullYear(), //month
"M+": this.getMonth() + 1, //month
"d+": this.getDate(), //day
"h+": this.getHours(), //hour
"m+": this.getMinutes(), //minute
"s+": this.getSeconds(), //secondsss
"w+": "日一二三四五六".charAt(this.getDay()), //week
"q+": Math.floor((this.getMonth() + 3) / 3), //quarter
"S": this.getMilliseconds() //millisecond
}
if (/(y+)/.test(style))
style = style.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o) {
if (new RegExp("(" + k + ")").test(style)) style = style.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
}
return style;
}
String.prototype.toTime = function () {
/// <summary>字符串转日期</summary>
/// <returns type="Date">返回日期</returns>
var val = this.match(/\d+|\D+/g);
var st = "";
if (val.length == 11 || val.length == 13)
st = val[0] + "/" + val[2] + "/" + val[4] + " " + val[6] + ":" + val[8] + ":" + val[10];
else if (val.length == 5)
st = val[0] + "/" + val[2] + "/" + val[4];
var dt = Date.parse(st)
return new Date(dt);
}
var NowData;
var today = new Date();
var oneday = 1000 * 60 * 60 * 24;
$("input[type = 'button']").click(function () {
console.log("点击");
NowData = ($.trim($("#NowData").val()) == "") ? dateFormatConversion(new Date(today - oneday * 7)) + "-" + dateFormatConversion(new Date()) : books.cli();
})
if ($.trim($("#NowData").val()) == "")
{
console.log("为空");
NowData = ($.trim($("#NowData").val()) == "") ? dateFormatConversion(new Date(today - oneday * 7)) + "-" + dateFormatConversion(new Date()) : books.cli();
}