Home > Back-end >  How to format this date so it's more readable?
How to format this date so it's more readable?

Time:06-29

I have date in this format:

2022-06-28T17:09:00.922108 01:00

I want to covert it into a more readable format. I'm using javascript/react and I tried moment-js but it gives me "invalid format".

What are my other options of turning it into a normal date?

CodePudding user response:

You can use this to format date:

const format = "DD-MM-YYYY"
moment(date).format(format)

or

moment().format('MMMM Do YYYY, h:mm:ss a');  // June 28th 2022, 9:49:49 pm

for more detail refer: https://momentjs.com/

CodePudding user response:

If you are using moment.js you can convert this to any format you like using this doc

Sample code

moment('2022-06-28T17:09:00.922108 01:00').format("DD-MM-YYYY"); //28-06-2022

Kindly go though the moment.js features and documents. There is a lot more you can do with this like showing time, day of the week etc

  • Related