日期:2014-05-16 浏览次数:20388 次
Date.prototype.getDayOfMonth = function(Mm){
var Feb = (this.getFullYear() % 4 == 0)?29:28;
var aM = new Array(31, Feb , 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
return (typeof Mm == 'undefined')?aM[this.getMonth()-1]:aM[Mm-1];
};
Date.prototype.getDateOfPreMonth = function(){
return new Date(
(this.getMonth() == 0)?(this.getFullYear()-1):this.getFullYear() ,
(this.getMonth() == 0)?11:this.getMonth() ,
this.getDayOfMonth(
(this.getMonth() == 0)?11:(this.getMonth()-1)
<=
this.getDate()
)?this.getDate():
this.getDayOfMonth(
(this.getMonth() == 0)?11:(this.getMonth()-1)
)
);
};
var d = new Date().getDateOfPreMonth();
alert(d);