convert date to new date format in javascript code example
Example 1: javascript convert date to yyyy-mm-dd
// `date` is a `Date` object
const formatYmd = date => date.toISOString().slice(0, 10);
// Example
formatYmd(new Date()); // 2020-05-06
Example 2: javascript date format
Modern JavaScript date utility library https://date-fns.org/
date-fns provides the most comprehensive, yet simple and consistent toolset for manipulating JavaScript dates in a browser & Node.js.