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?
CodePudding user response:
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>
CodePudding user response:
You can format it
const options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
new Date('2022-09-13T08:06:12.328 0000').toLocaleDateString('de-DE', options)