从别人学到的一点东西-日期处理
//日期格式化
Date.prototype.Format = function (time) {
var o = {
“M+”: this.getMonth() + 1,
“d+”: this.getDate(),
“H+”: this.getHours(),
“m+”: this.getMinutes(),
“s+”: this.getSeconds()
};
if (/(y+)/.test(time)) {
time = time.replace(RegExp.$1, (this.getFullYear() + “”).substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp("(" + k + “)”).test(time)) {
time = time.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : ((“00” + o[k]).substr(("" + o[k]).length)));
}
}
return time;
}
//获取当前时间
var time = new Date().Format(“HH:mm”);
var date = new Date().Format(“yyyy-MM-dd”);
原博地址找不到了,抱歉了,鞠躬