How to display current date and time in html using javascript?

Today, We want to share with you display current date and time in html using javascript.In this post we will show you javascript get current date yyyy-mm-dd, hear for javascript get current time in 24 hour format we will give you demo and example for implement.In this post, we will learn about javascript get today date with an example.

JavaScript – Display current Date and Time

here you can learn to javascript get today date as well as javascript current time. Throughout, In this tutorial you’ll learn javascript get date.This article goes in detailed on implementing javascript get current time in 24 hour format.If you want to learn display current date and time in html using javascript. So, from this post, you can find step by step process of doing javascript date format.

Read Also:  Laravel 5.7 JQuery AJAX Tutorial Example

Function to Display Current System Date and Time

Example 1: JavaScript function

<script type="text/javascript">
	function getCurrentDate(){
		var activedt=new Date();
		document.getElementById("showDate").innerHTML = activedt.toString();
	}
</script>

HTML Source Code with JavaScript

index.html

<!--JavaScript to display current Date and Time.-->
<html>
	<head>
		<title>JavaScript to display current Date and Time.</title>
		<script type="text/javascript">
			function getCurrentDate(){
				var activedt=new Date();
				document.getElementById("showDate").innerHTML = activedt.toString();
			}
		</script>
	</head>
<body onLoad='getCurrentDate()' style="text-align: center">
    <h1>Get current date using JavaScript.</h1>
    <!--Here date and time will display-->
    <h2 id="showDate"></h2>
</body>

</html>

I hope you get an idea about display live date and time in html using javascript.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.