PDA

View Full Version : Need help with time script



Marquis
01-23-2014, 12:18 AM
Hi, i need help with following script wich i use to to display different content depending on the time of day. But between 0 and 1 nothing is displayed. Whats wrong?



function goto(){

var today=new Date();
var hour=today.getHours();
if((hour>0) && (hour<=11)){

}

else if((hour>11) && (hour<=18)){
}

else if((hour>18) && (hour<=0)){
}

}

goto();

jscheuer1
01-23-2014, 03:17 AM
Nothing is displayed for anything in that code. And in addition to that, this:


else if((hour>18) && (hour<=0)){

can never be true.

This would be more efficient:


function goto(){

var today=new Date();
var hour=today.getHours();
if (hour < 12) {

}

else if (hour < 19) {
}

else {
}

}

goto();