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 data time to a desired format in js

I am trying to convert 2022-09-13T08:06:12.328+0000 to 13 September at 1:36 PM using javascript. In order to make things easier, I thought to install moment js and tried the conversion as below.

console.log(moment('2022-09-13T08:06:12.328+0000').calendar());

But it will print the output as Yesterday at 1:36 PM. So is there any way to change the format as I expected above(13 September at 1:36 PM) or any other best way to achieve it?

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

>Solution :

You could use this format :

console.log(moment('2022-09-13T08:06:12.328+0000').format('D MMMM [at] h:mm A'));
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"></script>
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