Friday, April 26, 2019

How to Display Date and Time in JavaScript

In this JavaScript program, you will learn how to display date and time in JavaScript. Display date and time in your webpage in JavaScript program. 



//Display Date and Time in JavaScript
<!DOCTYPE html>
<html>
<body>

<h1>My First JavaScript</h1>

<button type="button"
onclick="document.getElementById('clock').innerHTML = Date()">
Click Here to Display Date and Time.</button>

<p id="clock"></p>

</body>
</html> 


The output of the program:

When you run this program in your browser, you can see that.

display date and time in javascript
Display Date and Time


When you click the option, Click Here to Display Date and Time, you can see that the default date and time in your computer.

display date and time in javascript
display date and time in javascript

0 comments:

Post a Comment