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 :

 

 

 

 

 

Author: Fabian Ros
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments