How to format a JavaScript date - Stack Overflow

PHOTO EMBED

Wed Jan 12 2022 19:24:40 GMT+0000 (UTC)

Saved by @yuio #javascript

function join(t, a, s) {
   function format(m) {
      let f = new Intl.DateTimeFormat('en', m);
      return f.format(t);
   }
   return a.map(format).join(s);
}

let a = [{day: 'numeric'}, {month: 'short'}, {year: 'numeric'}];
let s = join(new Date, a, '-');
console.log(s);
content_copyCOPY

https://stackoverflow.com/questions/3552461/how-to-format-a-javascript-date