-4

I have tried quite a few methods to do date format in javascript but all that looked lengthy am looking for any short way to deal with this date format. I want to change the current system date to DD-MON-YYYY HH12:MI:SS:AM format in javascript, has anybody have any idea on this.

Forgot to mention: I do not want to use momento.js

Not A Bot
  • 2,220
  • 2
  • 10
  • 24
Rajesh Acharya
  • 55
  • 1
  • 1
  • 13
  • ``let d = new Date(); let date = d.getDate(); let month = d.getMonth() + 1; let year = d.getFullYear(); let hours = d.getHours(); let minutes = d.getMinutes(); let seconds = d.getSeconds(); console.log(date, month, year, hours, minutes, seconds);`` Format accordingly. – Not A Bot Mar 10 '20 at 09:47

1 Answers1

0

By using that cool moment library you can solve your problem like below code.

    var date = new Date();
console.log(moment(date).format('DD-MON-YYYY h:mm:ss A'))