Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

convert js datetime to moment

I have this format of datetime currently stored in res.data[i].time:

2022-05-18T13:00:00.000Z

what I want to do is convert it to moment format. When i do this:

moment().toDate()

it gives me this:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Tue May 10 2022 13:00:00 GMT-0400 (Eastern Daylight Saving Time)

what I want to need to do is convert 2022-05-18T13:00:00.000Z to moment somehow. I tried:

moment().toDate(res.data[i].time)

but that doesn’t work either. is there a way to do this?

>Solution :

Just let whatever = moment(res.data[i].time) should instantiate the moment object with the time string provided. You can then do whatever you need from there.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading