Date and Time in Javascript


Program:

<html>

<head>
</head>

<body>

</br>
</br>
</br>

<h1>
<div id='para1' style='text-align: center'></div>
</h1>

<script type="text/javascript" >
startTime();
function startTime() {
    var date = new Date();
    var calendar = date.toDateString();
    var time= date.toLocaleTimeString();
    document.getElementById("para1").innerHTML = 'Date: '+calendar +'<br/> Time: '+time;
    var t = setTimeout(function() {
                startTime();
        }, 1000);
}
</script>

</body>

</html>

Output:


No comments:

Post a Comment