Slip 15 - A) Write a JavaScript program to Display current Day, Date, Month, Year and Time on the web page and greet the user accordingly.

Solution:


<html>
<body>
<script language="JavaScript">
dt = new Date();
month = dt.getMonth()+1;
27
day = dt.getDate();
year = dt.getFullYear();
alaert(day+':'+month+':'+year);
var h=dt.getHours();
if(h>=5 && h<12)
{
alert("Good Morning "+"Timing: "+h);
}
else
if(h>=12 && h<17)
{
alert("Good Afternoong"+"Timing: "+h);
}
else
if(h>=17 && h<21)
{
alert("Good Evening"+h);
}
else
{
alert("Good Night"+h);
}
</script>
</body>
</html>

Post a Comment

1 Comments

  1. Some spelling mistakes are there and some of the programs do not run....What to do to run the program?

    ReplyDelete