format iso 8601 to date(YYYY-MM-DD) using luxon

1.1k Views Asked by At

How to use Luxon to convert date data

api data

2021-09-05T01:39:33Z

data conversion results I want

2021-09-05

I'd appreciate your help.

1

There are 1 best solutions below

1
Gultekin Ahmed On
let format = `YYYY-MM-DD`;

let now = new Date();

let result = `${now.getFullYear()}-${(now.getMonth() < 10) ? "0" + now.getMonth() : now.getMonth()}-${(now.getDate() < 10) ? "0" + now.getDate() : now.getDate() }`;

console.log(result);