that formatting Date objects as strings
npm i @aierse/date-format
Do not use the spacebar as a separator.
import dateFormat from "@aierse/date-format";
const now = new Date("2023-09-14 12:20:30");
const type1 = dateFormat(now); // 2023-09-14
const type2 = dateFormat(now, "yyyy"); // 2023
const type3 = dateFormat(now, "yyyy/MM/dd"); // 2023/09/14
const type4 = dateFormat(now, "MM-dd-yyyy"); // 09-14-2023
const type5 = dateFormat(now, "M-d-yyyy"); // 9-14-2023
const type6 = dateFormat(now, "yyyy-MM-dd hh:mm:ss"); // 2023-09-14 12:20:30
const type7 = dateFormat(now, "hh:mm"); // 12:20
const type8 = dateFormat(now, "hh:mm yyyy-MM-dd"); // 12:20 2023-09-14