YogeshChauhan.com
How to convert datetime to date format in JavaScript?
November 21, 2020

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
dreamhost

Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 5 How to create flickering text using CSS? Mar 4 How to use data-* Attributes in HTML? Mar 4 The substr() method in JavaScript and how it’s different from substring() Mar 4 A complete guide to add responsive YouTube videos using HTML and CSS Mar 3 How to embed YouTube or other video links in WordPress? Mar 3 How to change the Login Logo in WordPress?

You might also like these

What are Web services?MiscCan we execute conditions in SQL?SQL/MySQLSQL ANY OperatorSQL/MySQLWhat is PostgreSQL? How similar or different it is from SQL?PostgresRBV Framework and closing of big brandsMiscHow to create two segues with two UIButtons on a single page (Swift 5.0)?SwiftFew more :nth-child examples in CSSCSSKeyValuePipe in Angular 9AngularWhat are CSS Specificity Rules and how does browser apply them?CSSJavaScript String Properties and MethodsJavaScriptWindow setInterval() Method in JavaScriptJavaScriptHow to get previous days or next days in PHP?PHP