-2

JS の日付を今日の日付と比較しようとしています。これは私のコードがどのように見えるかです。しかし、2014 年 1 月 7 日の日付を比較しようとすると、これは機能しません。私は何を間違っていますか?

var chsRedirectDate = "04/01/2013" ; //new Date("1 Apr 2013");
var today = new Date();
var dd    = today.getDate();
var mm    = today.getMonth()+1; //January is 0!
var yyyy  = today.getFullYear();

if(dd<10){dd='0'+dd};
if(mm<10){mm='0'+mm};

today = mm+'/'+dd+'/'+yyyy;


if (ee_value.toUpperCase() == 'TEST123') && (today >= chsRedirectDate))
   var url = "test.php" ;
   var newtab = window.open("url", null, "top=190,left=450, dependent=yes, directories=no,location=no,menubar=no,status=no,toolbar=no,titlebar=no,scrollbars=no,width=500,height=250,resizable=yes");
   window.close();
   newtab.location = url;
   newtab.focus();

   return false;

}

if (ee_value.toUpperCase() == 'TEST123') && (today < chsRedirectDate))
{
   alert('Testing');
}
4

1 に答える 1

1
var today = new Date();
var otherDay = new Date("04/01/2013");

alert(today >= otherDay);
于 2013-01-07T19:06:45.297 に答える