Following JavaScript code snippet can be used to rotate/change an image based on the time:
<script language="JavaScript" type="text/javascript">
var now = new Date();
var hour = now.getHours();
if (hour <=11){
var ImageTag = "<img src="image1.jpg">"
}else if(hour > 11 && hour <= 17){
var ImageTag = "<img src="image2.jpg">"
}else if(hour > 17){
var ImageTag = "<img src="image3.jpg">"
}
</script>
<script>
document.write(ImageTag)
</script>
We used two script block to determine what image to display.
In the first block, we are checking the current time and based on which an image will be displayed. We are dispaying image1.jpg if time is before 11, image2.jpg if time is in between 12 to 17, and displaying image3.jpg if time is greater then 17. This script block will be placed within the HEAD tags of the web page.
The second script block is used to display the image using the document.write statement. This script block will be placed within the BODY tag where you would want to display the image.