We can format it using toDateString().

It convert any date into a readable string.

Example


var date = new Date();
var readable_date = date.toDateString();
console.log(readable_date);

// Tue Jun 09 2020

The toDateString() method converts the date (not the time) of a Date object into a readable string.

Our goal is to convert into date so we are not worried about time conversion in this post.

The method is supported by all major browsers.

You can convert any datetime format into a date format.

Example 2


var date = "2020-01-15T05:12:59Z";
var readable_date = new Date(date).toDateString();
console.log(readable_date);

// Wed Jan 15 2020

Example 3


var date = "2020-06-08T22:50:00.000+02:00";
var readable_date = new Date(date).toDateString();
console.log(readable_date);

// Mon Jun 08 2020

0 Comments

Leave a reply

Your email address will not be published. required fields are marked *