Displaying a different image depending on the time of the day
With the above knowledge, and a little HTML, you can display different images according to the date/time. Here is a common example: Displaying a different image depending on whether it is mourning or night.
Lets first get two images: (One for mourning, one for night.)
var current= new Date() var day_night=current.getHours() if (day_night<=12) document.write("<img src='day.gif'>") else document.write("<img src='night.gif'>")
There is one very important concept here:
What else can you do with this object? Plenty. How about a live clock? Well, that is really fairly easy to do, provided we know this very important function: setTimeout().