Javascript Date Format Change Example


Share:
Published By: Admin, Published On: Apr 16, 2021, Category: Javascript

Hello Friends,

Now let's see example of how to change date format example. We will use how to change date format in javascript. Here you will learn how to use javascript change date format. This is a short guide on date format change. Let's get started with how to change date format in javascript.

Here i will give you many example how you can change javascript date format.

Example: 1
<!DOCTYPE html>
<html>
<head>
   <title>Javascript - How to change date format?-MyWebtuts.com</title>
</head>
	<body>

	<h2>JavaScript Date Format Function</h2>

	<p id="stud"></p>

		<script>

			var a = new Date("03/25/2015");
			document.getElementById("stud").innerHTML = a;
		
		</script>

	</body>
</html>
Output: 1
Wed Mar 25 2015 00:00:00 GMT+0530 (India Standard Time)
Example: 2
<!DOCTYPE html>
<html>
<head>
   <title>Javascript - How to change date format?-MyWebtuts.com</title>
</head>
	<body>

	<h2>JavaScript Date Format Function</h2>

	<p id="test"></p>

	<script>

		var x = new Date("Jan 25 2015");
		document.getElementById("test").innerHTML = x;

	</script>

	</body>
</html>
Output: 2
Sun Jan 25 2015 00:00:00 GMT+0530 (India Standard Time)

It will help you...

Share: