JavaScript Tutorial

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>
<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>

Output :






Leave a Reply

Your email address will not be published. Required fields are marked *