date formatting from date string in javascript code example

Example 1: javascript format date

var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var today  = new Date();

console.log(today.toLocaleDateString("en-US")); // 9/17/2016
console.log(today.toLocaleDateString("en-US", options)); // Saturday, September 17, 2016
console.log(today.toLocaleDateString("hi-IN", options));

Example 2: 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}`)

Tags:

Php Example