Setting Date Format in JavaScript as dd/mm/yyyy hh:mm:ss

Vishalneeraj-24503
Posted by Vishalneeraj-24503 under JavaScript category on | Points: 40 | Views : 1370
Write below javascript code:-
<script type="text/javascript">
function getdates()
{
var today = new Date()
document.getElementById('lblCurrentDate').innerHTML = today;
document.getElementById('lblPreviousDate').innerHTML = [today.getDate(), today.getMonth() + 1, today.getFullYear()].join('/');
document.getElementById('lbldateformat').innerHTML = [today.getDate(), today.getMonth() + 1, today.getFullYear()].join('/') + ' ' + [today.getHours(), today.getMinutes(), today.getSeconds()].join(':');
}
</script>
<label id = "lblCurrentDate" />
<label id = "lblPreviousDate" />
<label id = "lbldateformat" />

Comments or Responses

Login to post response