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

Q50 How do I show a customized message based on the time of day?

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

<script language="JavaScript"><!--
var date = new Date();
var hours = date.getHours();
if ( (hours < 6) || (hours >= 22) )
    document.write("Good Night")
else if ( (hours >= 19) && (hours < 22) )
    document.write("Good Evening")
else if ( (hours >= 6) && (hours < 9) )
    document.write("Good Morning")
else
    document.write("Good Day");
//--></script>

©2018 Martin Webb