Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Date Comparisons
Message
From
05/01/2006 10:25:41
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
 
 
To
All
General information
Forum:
Internet
Category:
Javascript
Title:
Date Comparisons
Miscellaneous
Thread ID:
01083547
Message ID:
01083547
Views:
65
I think the two alerts below should have the same value, but they are slightly different. The begtrandate variable is in the format mm/dd/yyyy and the mintrandate is in the default (time?) format. What I really need to do is set the mintrandate variable to the current date minus a certain number of days (or full years, preferably). I'm reasonably new to Javascript and can't seem to find the right solutions online for this. Looks like I'll be doing a fair amount more in the near future, so any help or resources are appreciated.
		//Set the two dates to compare
		var mintrandate=new Date();
		var begtrandate=new Date(document.ERLiabHis.BegTranRange.value);

		alert("Beg: " + begtrandate.getTime());
		alert("Min: " + mintrandate.getTime());

		if (begtrandate.getTime() < mintrandate)
		{
          mvalid = "f";
		  alert("The Start Date must be no more than 2 years prior to today's date.");
	      document.ERLiabHis.BegTranRange.focus();
	      document.ERLiabHis.BegTranRange.select();
	      event.returnValue=false;
          return false;
		}
Next
Reply
Map
View

Click here to load this message in the networking platform