SyntaxFix
Write A Post
Hire A Developer
Questions
A better version of answer by @Hozefa.
If you have date-fns installed, you could use formatISO function
date-fns
const date = new Date(2019, 0, 2) import { formatISO } from 'date-fns' formatISO(date, { representation: 'date' }) // '2019-01-02' string