How to convert this date string "2021-09-22T09:00:00" into standard format

Asked

Viewed 23 times

0

I get that string in a request "2021-09-22T09:00:00"

I need to turn her into this pattern with 22/09/2021 09:00 javascript

Can someone help me? I need a regex to modify

  • Basically, create the date with var data = new Date("2021-09-22T09:00:00") and then choose some method described in the various responses in the links indicated above in the blue box. Note the methods that use the getters (getMonth(), getHours(), etc) versus toISOString(), because there is an important detail explained here (for "local time" x UTC)

  • Taking advantage, nay use regex, is the worst way to do (the ways that are in the indicated links are better). On the use of regex to validate dates, I comment a little in this answer and in the second half of this other answer, and there are also examples in this question. But perhaps it’s best to follow the recommendation of this answer and instead of regex, use language resources that are specific to treat dates.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.