Morning or Evening
<!-- Example File From "JavaScript and DHTML Cookbook" Published by O'Reilly & Associates Copyright 2003 Danny Goodman --> function dayPart() { var oneDate = new Date(); var theHour = oneDate.getHours(); if (theHour < 12) { return "morning"; } else if (theHour < 18) { return "afternoon"; } else { return "evening"; } } <script language="JavaScript" type="text/javascript"> <!-- document.write("Good " + dayPart() + " and welcome") //--> </script>