How to Get System time and print Appropriate message according time using HTML and JavaScript
Program:
| <html> | |
| <head> | |
| </head> | |
| <body> | |
| <script type="text/javascript"> | |
| var date=new Date(); | |
| var hour=date.getHours(); | |
| var min=date.getMinutes(); | |
| document.write("THE TIME IS: "+hour+":"+min); | |
| if(hour>0 && hour<12) | |
| { | |
| document.write("<h1>Good Morning</h1>"); | |
| } | |
| if(hour>=12 && hour<18) | |
| { | |
| document.write("<h1>Good Afternoon</h1>"); | |
| } | |
| if(hour>=18 && hour<24) | |
| { | |
| document.write("<h1>Good Evening.</h1>"); | |
| } | |
| </script> | |
| </body> | |
| <html> |
No comments:
Post a Comment