<html
xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="Scripts/jquery-2.1.4.min.js"></script>
<link href="Content/bootstrap.min.css" rel="stylesheet" />
<title>Javascript set date format </title>
</head>
<body >
<h3>Date Format</h3>
<br />
<form id="form1" class="form">
<div class="form-group">
<b>Current Date:</b>
<label id="Lbl_Curr_Date" style="color:blue" />
</div>
<div class="form-group">
<b>dd mm yyyy format:</b>
<label id="Lbl_format_1" style="color:blue" />
</div>
<div class="form-group">
<b>mm dd yyyy format </b>
<label id="lbl_format_2" style="color:blue"></label>
</div>
<div class="form-group">
<b>dd mm yyyy hh:mm:ss Format:</b>
<label id="lbl_format_3" style="color:blue" />
</div>
</form>
</body>
</html>
<script type="text/javascript">
$(document).ready(function()
{
var today = new Date()
document.getElementById('Lbl_Curr_Date').innerHTML = today;
document.getElementById('Lbl_format_1').innerHTML = [today.getDate(), today.getMonth() + 1, today.getFullYear()].join('/');
document.getElementById('lbl_format_2').innerHTML = [today.getMonth() + 1, today.getDate(), today.getFullYear()].join('/');
document.getElementById('lbl_format_3').innerHTML = [today.getDate(), today.getMonth() + 1, today.getFullYear()].join('/') + ' ' + [today.getHours(), today.getMinutes(), today.getSeconds()].join(':');
})
</script>From this code snippet you will learn how to format the date in particular format using JavaScript.
