假设我以DD/MM/YYYY
var date1 = '25/02/1985'; /*february 25th*/
var date2 = '26/02/1985'; /*february 26th*/
/*this dates are results form datepicker*/
if(process(date2) > process(date1)){
alert(date2 + 'is later than ' + date1);
}
这个功能应该是什么样的?
function process(date){
var date;
// Do something
return date;
}
答案 0 :(得分:25)
答案 1 :(得分:7)
function process(date){
var parts = date.split("/");
var date = new Date(parts[1] + "/" + parts[0] + "/" + parts[2]);
return date.getTime();
}
答案 2 :(得分:6)
可能会更容易:
var date1 = '25/02/1985'; /*february 25th*/
var date2 = '26/02/1985'; /*february 26th*/
if ($.datepicker.parseDate('dd/mm/yy', date2) > $.datepicker.parseDate('dd/mm/yy', date1)) {
alert(date2 + 'is later than ' + date1);
}
了解更多详情check this。感谢。