标签:
<script language="JavaScript" type="text/javascript">
function dater(sj)
{
var num=Math.abs(sj);
var dd = new Date();
var str="";
var fuhao;
num==sj?fuhao=1:fuhao=-1;
for(var i=1;i<=num;i++){
dd.setDate(dd.getDate()+fuhao);
var y = dd.getYear();
var m = (dd.getMonth()+1)<10?"0"+(dd.getMonth()+1):(dd.getMonth()+1);
var d = dd.getDate()<10?"0"+dd.getDate():dd.getDate();
str+=y+"-"+m+"-"+d+"<br>";
}
return str;
}
document.write("<br />一月前:"+dater(-30));
</script>
标签:
原文地址:http://www.cnblogs.com/hshanghai/p/4448106.html