Reputation: 832
I'm receiving date from an endpoint in the following format: yymmdd
Example: 210626
What I need is to change the format to DD/MM/YYYY
maybe using momentJS or something else.
I tried several momentJS methods and some custom function I didn't came up with any solution.
Upvotes: 1
Views: 286
Reputation: 1
I can recommend format
method from the date-fns
for such purpose
https://date-fns.org/v1.30.1/docs/format
In overall date-fns
is much lighter than momentJS
and switching on it in your projects may be a good idea.
Upvotes: 0
Reputation: 479
With moment is pretty easy
moment("210626", "YYMMDD").format("DD/MM/YYYY")
//"26/06/2021"
Upvotes: 5