• HTML lang="en"
    • HEAD
      • #text:
      • TITLE
        • #text: Displaying Times and Dates
      • #text:
    • #text:
    • BODY
      • BOLD
        • #text:
        • H1
          • #text: Current Date and Time
        • #text:
        • SCRIPT type="text/javascript"
          • #text: now = new Date (); localtime = now.toString(); utctime = now.toGMTString(); document.write("<p><strong>Local time:</strong>" + localtime + "</p>"); document.write("<p><strong>UTC time:</strong> " + utctime + "</p>"); var myDate = new Date(); /* hour is before noon */ if ( myDate.getHours() < 12 ) { document.write("Good Morning!"); } else /* Hour is from noon to 5pm (actually to 5:59 pm) */ if ( myDate.getHours() >= 12 && myDate.getHours() <= 17 ) { document.write("Good Afternoon!"); } else /* the hour is after 5pm, so it is between 6pm and midnight */ if ( myDate.getHours() > 17 && myDate.getHours() <= 24 ) { document.write("Good Evening!"); } else /* the hour is not between 0 and 24, so something is wrong */ { document.write("I'm not sure what time it is!"); }
        • P
          • STRONG
            • #text: Local time:
          • #text: Wed Dec 23 2015 16:38:48 GMT-0500 (Eastern Standard Time)
        • P
          • STRONG
            • #text: UTC time:
          • #text: Wed, 23 Dec 2015 21:38:48 GMT
        • #text: Good Afternoon!