SharkBait Posted August 31, 2007 Share Posted August 31, 2007 I seem to be having troubles comparing dates in Javascript. This is how I am doing it function checkTime(id) { var DoM = document.getElementById(id).value; var Today = new Date(); var Minute = 60 * 1000; var Hour = Minute * 60; var Year = Hour * 365; var difference; Today = Today.getTime(); DoM = Date.parse(DoM); difference = Today - DoM; if(difference > Year) { alert("OOW"); } alert("Today: " + Today +"\n DoM: "+ DoM +"\n Year: "+ Year +"\n Difference: "+ difference); } the value for the id would look like "2006-04-12" and I don't think I am comparing them properly. I am trying to convert them to Unix time.. find the difference between today's date and the date entered and then see if it is greater than 1 year. Quote Link to comment Share on other sites More sharing options...
php_tom Posted September 2, 2007 Share Posted September 2, 2007 I think you want: var Year = Hour * 24 * 365; Post back if it doesn't help. Quote Link to comment Share on other sites More sharing options...
SharkBait Posted September 4, 2007 Author Share Posted September 4, 2007 Lol thanks that works nicely Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.