-2

In javascript I need to change the current date in the following format?I googled a lot but I didnt find the exact result.

I'm expecting the current date to format is 22-Sep-2017 13:37:02

Thanks in Advance

User
  • 45
  • 9

1 Answers1

0

var ele = document.getElementsByTagName('h3')[0];

setInterval(function(){
 var date =new moment().format('DD-MMM-YYYY hh:mm:ss');
 ele.innerHTML = date;}
 ,1000);
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.js"></script>
<h3></h3>

Use momentjs and format your date according to your need.

Durga
  • 13,489
  • 2
  • 19
  • 40