Javascript - Write program to display current time on a web page

Requirements

Write program to display current time on a web page.

Trigger the display from a button

Hint

Use Date class.

Demo

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>
          //from  w  w w . j  a  va 2 s  . co m
<h2>My First JavaScript</h2>
          
<button type="button"
         onclick="document.getElementById('demo').innerHTML = Date()">
         Click me to display Date and Time.</button>
          
<p id="demo"></p>
          
</body>
</html>