List Last x Days
May 17th, 2005 by Intermanaut
To show the dates for Today – x days, set the value of x accordingly.
<script type=”text/javascript”>
<!–
DateToday = new Date();
x=7;
for (y=0; y<x; y++)
{
MyDate = new Date(Date.UTC(parseInt( _
DateToday.getYear()), _
parseInt(DateToday.getMonth()), _
parseInt(DateToday.getDate()))- _
(60*60*24*1000*y));
MyDateString=MyDate.getDate() + ‘.’ _
+ parseInt(MyDate.getMonth()+1) _
+ ‘.’ + MyDate.getYear();
document.write (MyDateString + “<br>”);
}
//–>
</script>