12.2. Static date and time on the Web

12.2.1. A page can say good morning

One simple use of time detection is to develop a Web page that can greet visitors with some voice messages depending on the time. A few seconds of voice messages such as “Good Morning” can give a warm welcome to your visitors and customers. Our next example shows how to divide the time into four sections with time-dependent text and voice messages. The structure of the page is listed below:

Display messageTiming rangeVoice file
Good MorningFrom 6 am To 12 amgm.wav
Good AfternoonFrom 0 pm To 5 pmga.wav
Good EveningFrom 5 pm To 12 pmge.wav
Please Go To BedFrom 0 am To 6 amgb.wav

If someone visits this page at, say, eight o’clock in the morning, the page will display the message ...

Get Practical Web Technologies now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.