Core JavaScript

Fill in the Date and Time

This JavaScript program shows how to fill in the date and time when a button is clicked.

FillInTheDateAndTime.html

<!DOCTYPE html>
<html>
	<head>
  	<title>XoaX.net's Javascript</title>
	</head>
	<body>
		<h3>Click the button to fill in the current date and time.</h3>
		<button type="button" onclick="document.getElementById('idDateTime').innerHTML = Date()">Button</button>
		<p id="idDateTime"></p>
	</body>
</html>
 

Output

 
 

© 2007–2025 XoaX.net LLC. All rights reserved.