Compare only date javascript

Posted by moleculezz on Stack Overflow See other posts from Stack Overflow or by moleculezz
Published on 2010-04-23T13:08:05Z Indexed on 2010/04/23 13:23 UTC
Read the original article Hit count: 355

Filed under:
|
|
|

Hi all, I can't seem to figure out what is wrong with my code. Maybe it would be simpler to just compare date and not time. Not sure how to do this either and I searched but couldn't find my exact problem.

BTW, when I display the two dates in an alert, they show as exactly the same.

My code:

window.addEvent('domready', function() {
var now = new Date();
var input = $('datum').getValue();
var dateArray = input.split('/');
var userMonth = parseInt(dateArray[1])-1;
var userDate = new Date();
userDate.setFullYear(dateArray[2], userMonth, dateArray[0], now.getHours(), now.getMinutes(), now.getSeconds(), now.getMilliseconds());

if(userDate > now)
{
    alert(now+'\n'+userDate);
}
});

Perhaps there is a simpler way to compare dates and not including the time. Hope someone has an answer...

Thanks!

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about date