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. Link to comment https://forums.phpfreaks.com/topic/67500-comparing-dates/ 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. Link to comment https://forums.phpfreaks.com/topic/67500-comparing-dates/#findComment-339619 Share on other sites More sharing options...
SharkBait Posted September 4, 2007 Author Share Posted September 4, 2007 Lol thanks that works nicely Link to comment https://forums.phpfreaks.com/topic/67500-comparing-dates/#findComment-341394 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.