Hello all....
I have a rotator on my site and I'm trying to set it up to where it will display certain images at 7p, 8p, 9p....and then the rest of the time it rotates as normal.
I looked online and found this script....
Code:
<script type="text/javascript">
<!--
var varTime = new Date(); // creates a new date object
var varDayNight = varTime.getHours(); // gets the time of the day in hours
if (varDayNight >= 6 && varDayNight <= 18 ) { // after 6am & before 6pm
document.write ("<img src='../../_assets/day.jpg' width='500' height='375' alt='Weclome to another day'>");
}
else {
document.write ("<img src='../../_assets/night.jpg' width='500' height='375' alt='Weclome to the night'>");
}
//-->
</script>
Here's my link:
http://tinyurl.com/3n6plwh
Now obviously that wouldn't work with my rotator, but it helped me get started.. I changed a couple of things, but it's still not working.
One problem is I don't have an idea of what to to put for "else" to have all the images rotate if it's not one of these times. The other problem is despite changing the if statements to
Code:
var varDayNight = varTime.getHours(); // gets the time of the day in hours
if (varDayNight >= 9 && varDayNight <= 10) {
document.getElementById("bbpage2");
}
if (varDayNight >= 20 && varDayNight <= 21) {
document.getElementById("bbpage3");
}
if (varDayNight >= 21 && varDayNight <= 22 ) {
document.getElementById("bbpage4");
}
else {
}
It Still won't display the correct image. Any help?
*Note I have the first image displaying at 9a because that's the current time. I'll eventually change it to 7p or 19 later