Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q468 How can I detect the hour of the day, and then when someone selects a link, they go to either a "day" page or a "night" page?

You are here: irt.org | FAQ | JavaScript | Date | Q468 [ previous next ]

Try this:

<SCRIPT LANGUAGE = 'JavaScript'><!--
var date = new Date();
var hours = date.getHours();
if ( (hours < 6) || (hours > 18) )
    document.write('<A HREF="night.html">click this link<\/A>');
else
    document.write(<A HREF="day.html">click this link<\/A>');
//--></SCRIPT>

©2018 Martin Webb