Javascript Code using Switch case and new Date() Functions , getDay() , getHours() , getMonth() , getFullYear() , getHours() , getMinutes()
<!DOCTYPE html>
<html>
<body>
<p id="demo"></p>
<script>
var day, month;
switch (new Date().getDay()) {
case 0:
day = "Sunday";
break;
case 1:
day = "Monday";
break;
case 2:
day = "Tuesday";
break;
case 3:
day = "Wednesday";
break;
case 4:
day = "Thursday";
break;
case 5:
day = "Friday";
break;
case 6:
day = "Saturday";
}
switch (new Date().getMonth()) {
case 0:
month = "January";
break;
case 1:
month = "February";
break;
case 2:
month = "March";
break;
case 3:
month = "April";
break;
case 4:
month = "May";
break;
case 5:
month = "June";
break;
case 6:
month = "Julyy";
case 7:
month = "August";
case 8:
month = "September";
case 9:
month = "October";
case 10:
month = "November";
case 11:
month = "December";
}
document.getElementById("demo").innerHTML = "Today is " + day +" Month: "+month +new Date().getDate() +" Year " +new Date().getFullYear() +"Time : " +new Date().getHours() +":"+new Date().getMinutes() ;
</script>
</body>
</html>
sample Output of this program:

Comments
Post a Comment