How to Change Date Format in JavaScript

JavaScript toLocaleString() method provides an easy way to convert date to a specific format. You can change the date format as per your needs using JavaScript.

The following code snippet shows how to change the format of a date or DateTime in JavaScript.

var dateTime = "2020-03-26 11:52:00";

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

var formattedDate = today.toLocaleDateString("en-US", options);

1 Comment

  1. Kusuma Said...

Leave a reply

keyboard_double_arrow_up