js date from format code example

Example 1: js date now format

new Date().toJSON()
// "2021-01-12T01:06:54.747Z"

Example 2: javascript date format

const event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));

const options = {  year: 'numeric', month: 'short', day: 'numeric' };

console.log(event.toLocaleDateString('de-DE', options));
// expected output: Donnerstag, 20. Dezember 2012

console.log(event.toLocaleDateString('en-US', options));
// US format 


// In case you only want the month
console.log(event.toLocaleDateString(undefined, { month: 'short'}));
console.log(event.toLocaleDateString(undefined, { month: 'long'}));

Example 3: Format Date Javascript

const dateStr = '2020-06-21T10:15:00Z',
      
      [yyyy,mm,dd,hh,mi] = dateStr.split(/[/:\-T]/)
      
console.log(`${dd}-${mm}-${yyyy} ${hh}:${mi}`)