Evertjan. wrote on 22 nov 2007 in comp.lang.javascript:
Randy Webb wrote on 22 nov 2007 in comp.lang.javascript:
var date = new Date(), m = date.getMonth() + 1;
if (m >= 11 || (m == 1 && date.getDate() <= 10)) {
A variation,
[this works EVERY year,
the year 2000 is just for internal use]:
var d = new Date(); d.setYear('2000');
if ( d >= new Date('2000/11/1') ||
d <= new Date('2000/1/10') )
alert('Merry Xmass')
else
alert('Bye');
I knew you would know better about that, John.
To keep the visual date [and missing the last minute]:
==================
var d = new Date(); d.setYear('2000');
if ( d >= new Date('2000/11/1') ||
d <= new Date('2000/1/10 23:59') )
alert('Merry Xmass')
else
alert('Bye');
==================
or:
==================
function between(dBegin,mBegin,dEnd,mEnd){
var d = new Date(); d.setYear('2000');
return ( d >= new Date('2000/'+mBegin+'/'+dBegin) ||
d <= new Date('2000/'+mEnd+'/'+dEnd+' 23:59') );
}
if ( between(1,11,10,1) ) // dBegin,mBegin,dEnd,mEnd
alert('Merry Xmass')
else
alert('Bye');
==================
or:
==================
function betweenUS(mBegin,dBegin,mEnd,dEnd){
...........
==================