How To Change Date Format in JavaScript?

Sep 25, 2021 . Admin



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 change date format. Let's get started with how to change date format in javascript.

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

Example : 1
<!DOCTYPE html>
<html>
		<head>
				<title>JavaScript Change Date Format - MyWebtuts.com </title>
				<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
		</head>
		<body class="bg-dark">
				<div class="container mt-5">
						<div class="row">
								<div class="col-md-6 offset-md-3">
										<div class="card">
												<div class="card-header">
														<h5>JavaScript Change Date Format</h5>
												</div>
												<div class="card-body">
														<p id="cmd"></p>
												</div>
										</div>
								</div>
						</div>
				</div>
				<script>
						const d = new Date("2021-03-22");
						document.getElementById("cmd").innerHTML = d;
				</script>
		</body>
</html>
Output :
Mon Mar 22 2021 05:30:00 GMT+0530 (India Standard Time)
Example : 2
<!DOCTYPE html>
<html>
		<head>
				<title>JavaScript Change Date Format - MyWebtuts.com </title>
				<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
		</head>
		<body class="bg-dark">
				<div class="container mt-5">
						<div class="row">
								<div class="col-md-6 offset-md-3">
										<div class="card">
												<div class="card-header">
														<h5>JavaScript Change Date Format</h5>
												</div>
												<div class="card-body">
														<p id="cmd"></p>
												</div>
										</div>
								</div>
						</div>
				</div>
				<script>
						const d = new Date("03/25/2020");
						document.getElementById("cmd").innerHTML = d;
				</script>
		</body>
</html>
Output :
Wed Mar 25 2020 00:00:00 GMT+0530 (India Standard Time)

It will help you...

#Javascript