Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Date | Q50 [ previous next ]

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

<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>

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 6th July 2009. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2009 irt.org, All Rights Reserved.