2013-10-10 96 views

回答

1

將字符串到日期:

// Expect d/m/yyyy 
function toDate(s) { 
    s = s.split(/\D/g); 
    return new Date(s[2],--s[1],s[0]); 
} 

然後比較當前日期:

function afterNow(s) { 
    var now = new Date(); 
    return +toDate(s) > +now; 
} 

試試:

afterNow('9/10/2013'); // false 
afterNow('9/10/2031'); // true 
相關問題