Display Time and Date – JavaScript Basics

This is very basic for beginners. At first let me show how to display current date and time with a button using JS.

JS Code :

<!DOCTYPE html>
 <html>
 <body>
<h1>Display Date and Time</h1>

<button type="button"
 onclick="document.getElementById('ex').innerHTML = Date()">
 Click Here To Display Current Date & Time.</button>

<p id="ex"></p>
</body>
 </html>

Output :

 

 

 

 

 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x