12345678910111213141516171819202122232425262728293031323334353637383940414243document.write("当前时间的36天前为:" + getNowFormatDate(36));function getNowFormatDate(s) {var date = new Date();var seperator1 = "-";var seperator2 = ":";var month = date.getMonth() + 1;var strDate = date.getDate();var shi = date.getHours();var fen = date.getMinutes();var miao = date.getSeconds();var nian = date.getFullYear();var sjif = strDate - s;if (sjif > 0) {strDate = sjif} else {var i = 1;sjif = sjif - sjif * 2 // 80//构造一个日期对象:var sgy = month - i;if (sgy <= 0) {sgy = sgy - sgy * 2;sgy = 12 - sgy;}if (s >= 365) {nian = nian - 1;}var day = new Date(date.getFullYear(), sgy, 0);//获取天数:var daycount = day.getDate();var yfif = daycount - sjif; // 31 - 80 = -49if (yfif > 0) {strDate = yfif;month = sgy;} else {dkbl()}
alert(getNowFormatDate(36));
直接调用36 为当前时间的36天前