ちょうど 1 か月間の 2 つの日付を比較しようとしています。検証には以下のコードを使用しました。この場合は次のように機能します。
からDate:1/5/2013
までDate:1/6/2013
ただし、2 月を考慮すると機能しません。たとえば、次のようになります。
fromDate:28/2/2013;
toDate:31/3/2013;
解決策を教えていただけますか?
以下のコード ( source ) を試しましたが、うまくいきません。
var fromDate = new Date(document.getElementById("Billing_From").value);
var toDate = new Date(document.getElementById("Billing_To").value);
fromDate.setMonth( fromDate.getMonth() + 1 );
if((fromDate-toDate) !=0)
{
alert("Please limit the date range to 1 month.");
}