﻿now = new Date();
hours = now.getHours();
mins = now.getMinutes();
secs = now.getSeconds();
ampm = " ";
document.write("<h2><strong>");
//document.write(now);
//document.write("</br>");
if (hours < 12) document.write("Good Morning");
else if (hours >= 12 && hours <= 17) document.write("Good Afternoon");
else if (hours > 17) document.write("Good Evening");
else document.write("Good Day");
document.write("</br>");
// Set AM or PM
if (hours >11) ampm=" PM"; 
else if (hours <12) ampm=" AM";
else ampm=" ";
// Set 24 hour time to 12 hour time
if (hours >12) hours =(hours-12);
//correct x:0:xx error
if (mins < 10) mins2 = "0" + mins;
else mins2=mins;
//correct x:xx:0 error
if (secs < 10) secs2 = "0" + secs;
else secs2=secs;
document.write("The current time is: ");
document.write(hours + ":" + mins2 + ":" + secs2 + ampm );
document.write("</strong>");
document.write("</h2>");

