0

I initialize my timestamp variable like

   var current_time = new Date();

My output is in Tue Oct 11 2016 15:09:04 GMT+0800 (Malay Peninsula Standard Time) format. How can I change it to 2016-10-11 07:19:48pm format?

Chan Yoong Hon
  • 1,592
  • 7
  • 30
  • 71
  • 4
    Maybe this previous question "How to format a JavaScript date" could help you: http://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date – Alberto Fortes Oct 11 '16 at 07:57
  • https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Date – freedomn-m Oct 11 '16 at 07:59

1 Answers1

1

you can acheive this using moment.js lib,

just run

moment().format('YYYY-MM-DD hh:mm:SS A'); // print 2016-10-11 03:20:88 PM
Alongkorn
  • 3,968
  • 1
  • 24
  • 41