Get the days time in the javascript

technical talkiess
0

 <!DOCTYPE html>

<html>

<body>


Days:- <h2 id="vishal"></h2>

Time:- <h1 id="horse"></h1><h2 id="min"></h2><h3 id="milisecond"></h3><h4 id="microsec"></h4>


<script>

let date = new Date();

let a = weekDaysreturn(date.getDay());

document.getElementById("horse").innerHTML = date.getHours();

document.getElementById("min").innerHTML =date.getMinutes();

document.getElementById("milisecond").innerHTML = date.getSeconds();

document.getElementById("microsec").innerHTML = date.getMilliseconds();


function weekDaysreturn(a){

switch(a){

case 0:

return 'Sunday';

break;

case 1:

return 'Monday';

break;

case 2:

return 'Thusday';

break;

case 3:

return 'Wednesday';

break;

case 4:

return 'Tuesday';

break;

case 5:

return 'friday';

break;

case 6:

return 'Saturday';

break;

default :

return "Not valid day";

}

}

</script>


</body>

</html> 


Tags

Post a Comment

0Comments

Thanks you for commenting your questions. I will see question and respond you.

Post a Comment (0)