I want to some message by date comparing in jquery.
for example:
I have a text box value as 04/01/2013 13:15:32
filled by userend.
And a current date time in jquery variable as 04/01/2013 18:30:12
if text box value is less then current datetime then show a message:
function foo(){
usrDate = jQuery("#txtDate").val(); //getting user input date time
currentDate = new Date(); //system current date
currentMonth = currentDate.getMonth() + 01;
currentDay = currentDate.getDate();
currentYear = currentDate.getFullYear();
currentHours = currentDate.getHours();
currentMinutes = currentDate.getMinutes();
currentSeconds = currentDate.getSeconds();
currentcpDateTime = currentMonth + "/" + currentDay + "/" + currentYear + " " + currentHours + ":" + currentMinutes + ":" + currentSeconds;
if (usrDate > currentcpDateTime ) {
alert("you can not choose date greater then current");
}
else {
alert("valid date");
}
}
each time wrong result. :(