Sunday, 19 November 2017

WT-Slip30



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

<html>
<head>
<script language="JavaScript">
 function Greetings()
{
var theDate=new Date();
var theHour=theDate.getHours();
if(theHour<=6)
{
alert("Early Good Morning.");
}
if((theHour>6)&&(theHour<=12))
{
alert("Good Morning.");
}
 if((theHour>12)&&(theHour<=17))
{
alert("Good Afternoon");
}
if(theHour>17)
{
 alert("Good Evening.");
}
 }
</script>
</head>
<body onload=Greetings();>

<script type="text/javascript">
var curdate=new Date();
document.write(curdate);
</script>
<center>
<h1>Greetings According to the times of the Day</h1>
</center>

</body>

</html>