I need to transform this date that comes from an API in this format
yyyy-mm-ddTHH:mm:ssZ
to
dd-mm-yyyy
do I have to use any library in order to do this?
I need to transform this date that comes from an API in this format
yyyy-mm-ddTHH:mm:ssZ
to
dd-mm-yyyy
do I have to use any library in order to do this?
It should be what you need:
let theDate=new Date("2022-07-26T03:00:11.183Z");
let option={
day:"2-digit",
month:"2-digit",
year:"numeric",
}
let result=theDate.toLocaleDateString('en-US',option).replaceAll("/","-")
console.log(result);
If you want the output in dd-mm-yyyy format, you can replace "en-US" with "en-GB".