How to use Date.toLocaleString() method In Javascript
The date.toLocaleString() method is used to convert a date and time to a string using the locale settings. The default settings for GMT.
Example: In this example, we will convert the date object to a string of locale format using the Date.toLocaleString() method.
// New date using date Constructor
let d = new Date()
// Convert to string
let dateString = d.toLocaleString(undefined,
{ timeZone: 'Asia/Kolkata' });
// Print output
console.log(dateString)
Output
9/20/2023, 2:12:52 PM
JavaScript Program to Convert Date to String
In this article, we will see how to convert a JavaScript Date to a string using JavaScript. We have a few methods to convert JavaScript Date to string which are described below.