我有以下内容;哪个工作正常,但我需要添加 之间的变量,给定日期将显示div。
var now = new Date();
var Date0 = new Date("November 12, 2015");
var Date1 = new Date("November 2, 2015"); // need to write between nov 2 - november 4
var Date2 = new Date("November 23, 2015");
var Date3 = new Date("November 22, 2015");
if(now > Date0) // today is after Christmas
{
$('#date_0').show();
}
if(now > Date1) // today is after Christmas
{
$('#date_1').show();
}
if(now > Date2) // today is after Christmas
{
$('#date_2').show();
}
if(now > Date3) // today is after Christmas
{
$('#date_3').show();
}
答案 0 :(得分:1)
使用&&与日期
if( new Date() < new Date("November 5, 2015") && new Date() > new Date("November 1, 2015"))
{
console.log('in') //this will run form 2 nov to 4th nov
}