我想在 jquery 中按日期比较一些消息。
例如:
我有一个由用户端填充的文本框值。04/01/2013 13:15:32
并且 jquery 变量中的当前日期时间04/01/2013 18:30:12
好像文本框值小于当前日期时间然后显示一条消息:
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");
}
}
每次都是错误的结果。:(