|
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>
|
|
|
Copyright © 1996-2008 irt.org, All Rights Reserved.