+ 1
Date string from POST API response to different format
Hi everyone! I have an array from an api response and it gives me the <startdate></startdate> as a string in the iso format. That’s fine, but I want to convert it to something simple like mm-dd-yyyy. Can anyone suggest how I can use typescript to reformat the response into a different output?
3 Réponses
+ 1
use date=new Date(iso_date) and your can format with Date object
https://www.javatpoint.com/typescript-date-object
0
Thank you Nyashi! Ill try it out when I get off work.
0
You can use moment library,
First install it,
2nd import moment in your desire component
3rd update format like
moment(new Date(api_date)). format('MM-DD-YYYY')