0
var monthDiff = today.getMonth() - pastdate.getMonth();
var hadBirthdayThisMonth =
(today.getMonth() > pastdate.getMonth()) ?
true : (today.getMonth() < pastdate.getMonth()) ?
false : (today.getDate() > pastdate.getDate()) ?
true : (today.getDate() < pastdate.getDate()) ? false : true;
if (!hadBirthdayThisMonth) monthDiff--;
8月20 2011年至2011年9月19日,天數是60,它顯示了2個月爲我,但我想說明它one
個月到他生日的Sept 20th
來。他這個月有沒有生日?
我想出了上述邏輯,但它不起作用。
神聖的嵌套三元運算符,蝙蝠俠! O_O – deceze
另外,問題是什麼?你只是想知道直到下一個生日有多少個月?或者僅僅是這個月的生日是不是? – deceze
*「我想出了上述邏輯,但它不起作用。」* - 我想知道爲什麼;) –