Morning or Evening : Time : Development JAVASCRIPT DHTML TUTORIALS


JAVASCRIPT DHTML TUTORIALS » Development » Time »

 

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>
           
       



-

Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .

Follow Navioo On Twitter

JAVASCRIPT DHTML TUTORIALS

 Navioo Development
» Time