yesterdays date from todays date?

admin

Administrator
Staff member
anyone know how you can change the value of a date set to today's date? I've been trying with a range of different scripts to no avail.

the latest one i tried to do:

<html><body>
<SCRIPT Language="JavaScript">
<!--
function BDDate(){
month = new Array();
month[0] = "January";
month[1] = "February";
month[2] = "March";
month[3] = "April";
month[4] = "May";
month[5] = "June";
month[6] = "July";
month[7] = "August";
month[8] = "September";
month[9] = "October";
month[10] = "November";
month[11] = "December";

dayName = new Array("", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")


var now = new Date();
var tDate
var i = now.getMonth();
var newday
var newdate
var newmonth
var newfullyear

if (dayName[now.getDay()] = "Wednesday")
{
newday = "Monday"
now.setDate(now.getDate()-2)
newmonth = month[now.getmonth()]
newfullyear = now.getFullYear();
}
else if (dayName[tDate.getDay()] = "Tuesday")
{
newday = "Monday"
newdate = now.getdate()-1
newmonth = month[now.getmonth()]
newfullyear = now.getFullYear();
}
else if (dayName[tDate.getDay] = "Monday")
{
newday = "Monday"
now.setDate(now.getDate())
newmonth = month[now.getmonth()]
newfullyear = now.getFullYear();
}
else if (dayName[tDate.getDay()] = "Thursday")
{
newday = "Monday"
newdate = now.getdate()-3
newmonth = month[now.getmonth()]
newfullyear = now.getFullYear();
}
else if (dayName[tDate.getDay()] = "Friday")
{
newday = "Friday"
newdate = now.getdate()
newmonth = month[now.getmonth()]
newfullyear = now.getFullYear();
}
else if (dayName[tDate.getDay()] = "Saturday")
{
newday = "Friday"
newdate = now.getdate()-1
newmonth = month[now.getmonth()]
newfullyear = now.getFullYear();
}
else if (dayName[tDate.getDay()] = "Sunday")
{
newday = "Friday"
newdate = now.getdate()-2
newmonth = month[now.getmonth()]
newfullyear = now.getFullYear();
}

tDate = newday + "-=-" + now.getDate() + "-=-" + now.getMonth() + "-=-" + now.getFullYear();

document.write('&nbsp;' + tDate + '&nbsp;&nbsp;');

}

BDDate();

//-->
</SCRIPT>
</body></html>
 
Back
Top