-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtime.html
More file actions
28 lines (27 loc) · 805 Bytes
/
Copy pathtime.html
File metadata and controls
28 lines (27 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Write a JavaScript program to Display current Day, Date, Month, Year and Time on the web page and greet the user accordingly
<html>
<body>
<form>
Enter User Name:
<input type="text" id="t1"> <br>
<input type="button" value="submit" onclick="greet()">
</form>
</body>
</html>
<script>
function greet()
{
var u=document.getElementById("t1").value;
var d1=new Date();
document.write("<br>Date & time="+d1);
var h=d1.getHours();
if(h>12&&h<=16)
document.write("<br>Good Afternoon:"+u);
else if(h>16&&h<=20)
document.write("<br>Good Evening:"+u);
else if(h>20&&h<=24)
document.write("<br>Good Night:"+u);
else
document.write("<br>Good Morning:"+u);
}
</script>