/*<HTML>
<HEAD><TITLE>Accessing the time portion of a JavaScript date (from JavaScript For Dummies, 3rd edition)</TITLE>
<SCRIPT LANGUAGE="JavaScript"> */

    var today = new Date()
    var hours = today.getHours()
    var minutes = today.getMinutes()
    var greeting
    var ampm

    // We consider one in the morning until just before noon "morning"
    if (hours <= 11) {
        greeting = "Good morning!"
        ampm="a.m."

        // JavaScript reports midnight as 0, so change it to 12
        // for display purposes.

        if (hours == 0) {
            hours = 12
        }
    }
    // We consider noon until five o'clock "afternoon"
    else if (hours > 11 && hours < 18) {
        greeting = "Good afternoon!"
        ampm="p.m."

        // We don't want to see military time, so subtract 12
        if (hours > 12) {
            hours-=12
        }
    }
    // We consider six until eight "evening"
    else if (hours > 17 && hours < 21) {
        greeting = "Good evening!"
        ampm="p.m."
        hours-=12
    }
    // We consider nine o'clock until midnight "night"
    else if (hours > 20) {
        greeting = "Good night!"
        ampm="p.m."
        hours-=12
    }

    // We want the minutes to display with "0" in front of them if
    // they're single-digit.  (For example, rather than 1:4 p.m.,
    // we want to see 1:04 p.m.

    if (minutes < 10) {
        minutes = "0" + minutes
    }

    document.write(greeting + "\nIt's " + hours + ":" + minutes + " " + ampm + ", ");

/* </SCRIPT>
</HEAD>
<BODY>
</BODY>
</HTML> */
