Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subtracting day from current date.

Status
Not open for further replies.

dinoviapangea

Technical User
Joined
Apr 9, 2002
Messages
41
Location
US
I'm trying to subtract one day from thet current date. My code is as follows:

function howlong(arg) {
if (length(arg)==1) {
arg = "0" + arg;
return arg;
}
else {
arg = arg;
return arg;
}
}
myDate = new Date();
dd = myDate.getDate()-1;
mm = myDate.getMonth();
yy = myDate.getFullYear();
switch (mm) {
case 0: mm = "Jan";
break;
case 1: mm = "Feb";
break;
case 2: mm = "Mar";
break;
case 3: mm = "Apr";
break;
case 4: mm = "May";
break
case 5: mm = "Jun";
break;
case 6: mm = "Jul";
break
case 7: mm = "Aug";
break
case 8: mm = "Sep";
break
case 9: mm = "Oct";
break
case 10: mm = "Nov";
break
case 11: mm = "Dec";
break
}
textdate = ( dd + " " + mm + " " + yy)

Worked fine until today, because it now shows May 0, 2003 for the yesterday. Any help would be appreciated.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top