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 :

