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:
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?
CodePudding user response:
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.
CodePudding user response:
If you want to use momentjs in any tag
<h3>{{ moment(res.data[i].time).format("DD.MM.YYYY") }}</h3>
and returns to you (approximately today's date)
11.05.2022
to get acquainted with detailed formats:
CodePudding user response:
Here is what Moment supports now.
moment("2010-10-20 4:30 0000", "YYYY-MM-DD HH:mm Z"); // parsed as 4:30 UTC
moment('24/12/2019 09:15:00', "DD MM YYYY hh:mm:ss");
moment('24/12/2019 09:15:00', "DD MM YYYY hh:mm:ss", true);
.
.
.
See this doc -> https://momentjs.com/docs/