<script type="text/javascript">
Date.prototype.Format = function(fmt)
{
//author: meizz
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(fmt))
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
for (var k in o)
if (new RegExp("(" + k + ")").test(fmt))
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
return fmt;
}
Date.prototype.addDays = function(d)
{
this.setDate(this.getDate() + d);
};
Date.prototype.addWeeks = function(w)
{
this.addDays(w * 7);
};
Date.prototype.addMonths= function(m)
{
var d = this.getDate();
this.setMonth(this.getMonth() + m);
if (this.getDate() < d)
this.setDate(0);
};
Date.prototype.addYears = function(y)
{
var m = this.getMonth();
this.setFullYear(this.getFullYear() + y);
if (m < this.getMonth())
{
this.setDate(0);
}
};
//測試 var now = new Date(); now.addDays(1);//加減日期操作 alert(now.Format("yyyy-MM-dd"));
Date.prototype.dateDiff = function(interval,endTime)
{
switch (interval)
{
case "s": //
主站蜘蛛池模板:
青州市|
宾阳县|
马龙县|
博兴县|
团风县|
乐清市|
文水县|
灵丘县|
赣州市|
舞阳县|
新兴县|
大英县|
惠水县|
迭部县|
雷波县|
余江县|
石棉县|
正定县|
民权县|
锦屏县|
乌拉特中旗|
广元市|
名山县|
巴南区|
健康|
姜堰市|
登封市|
道孚县|
镇原县|
浪卡子县|
阳西县|
贺州市|
武宣县|
柳河县|
乌鲁木齐市|
静海县|
凤山县|
清徐县|
额尔古纳市|
济源市|
德安县|