<center> <h2 style="color:blue;"> How To Create Greetings Message Using JavaScript </h2> <script> var Time_of_The_Day=new Date() var hours=Time_of_The_Day.getHours() if (hours>=5&&hours<=11) //GREETING MESSAGE FOR MORNING document.write('<h2>Hello! Good Morning! Have a nice day.</h2>') else if (hours==12) //GREETING MESSAGE FOR NOON document.write('<h2>Good Noon Visitor! </h2>') else if (hours>=13&&hours<=17) //GREETING MESSAGE FOR AFTERNOON document.write('Example:<h2 style="color:#1982d1;">Good Afternoon! </h2>') else if (hours>=18&&hours<=20) //MESSAGE FOR EVENING (6pm-8pm) document.write('<h2>Good Evening! </h2>') else if (hours>=21&&hours<=11) //GREETING MESSAGE FOR NIGHT (9pm-11pm) document.write('<h2>Good Night! </h2>') else //GREETING MESSAGE FOR LATE NIGHT (12pm-4am) document.write('<h2>Wow! You`re still awake. Working Late?</h2>') </script> </center>