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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Converting to wrong date

Status
Not open for further replies.

faiyth

Programmer
Nov 22, 2002
19
US
I need to be able to convert 6-2-04 into 06-02-2004, right now it's being converted to 06-02-1904.. I need to add like.. 1000 years.. heh! what can I do to make it see 99 as 1999 but 04 as 2004?

Code is below:

function checkForDate(strPassed) {
var newDate = new Date();
newDate.setTime(Date.parse(strPassed.value));
strPassed.value=newDate.getMonth() + 1 + "-" + newDate.getDate()+ "-" + newDate.getFullYear();
}
 
Actually nevermind I figured out something that will work..

if(newDate.getFullYear() < 1990) { newyear=newDate.getFullYear()+100; }
else { newyear=newDate.getFullYear(); }
strPassed.value=lz((newDate.getMonth() + 1)) + "-" + lz(newDate.getDate()) + "-" + newyear;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top