1

I want to generate this date format using Moment.js:

Mon Apr 1 17:51:40 2019

Right now, I am getting this format instead:

Mon Apr 01 2019 17:51:40 GMT+0530 (IST)
4
  • 2
    Look at the documentation for Date object - it's all there Commented Apr 2, 2019 at 5:10
  • your problem looks same like this. stackoverflow.com/questions/15993913/format-date-with-moment-js. I hope this will help you.. Commented Apr 2, 2019 at 5:15
  • I down voted this post because the OP did not have any attempt or code to solve the problem. And probably did not check the documentation of the mentioned library, which would actually have the answer right in the landing page: momentjs.com Commented Apr 2, 2019 at 5:33
  • @ektasahu , can you tell me how is that answer is correct and you should note the time that how have given the answer first and then you mark the answer as correct Commented Apr 2, 2019 at 6:21

4 Answers 4

1

use this:

Moment(new Date(this.state.date)).format('MMMM Do YYYY, h:mm:ss a')

or whatever format you want. you can check them on here: https://momentjs.com/

Sign up to request clarification or add additional context in comments.

Comments

1

Try this:

 var dateTime = new Date("Mon Apr 01 2019 17:51:40 GMT+0530 (IST)");
 dateTime = moment(dateTime).format("ddd MMM D HH:mm:ss YYYY");

Comments

0

It's already a valid date string - just make a new Date:

console.log(new Date("Mon Apr 01 2019 17:51:40 GMT+0530 (IST)"));

Comments

0

first you need to install moment

 let formatedDate = moment('Mon Apr 01 2019 17:51:40 GMT+0530 (IST)').format('ddd MMM DD HH:mm:ss YYYY');
 console.log(formatedDate)

output: Mon Apr 01 17:51:40 2019

Done You can check it

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.