VOOZH about

URL: https://www.geeksforgeeks.org/javascript/javascript-date-tolocalestring-method/

⇱ JavaScript Date toLocaleString() Method - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

JavaScript Date toLocaleString() Method

Last Updated : 11 Jul, 2025

The date.toLocaleString()method is used to convert a date and time to a string using the locale settings.

Syntax:

dateObj.toLocaleString(locales, options)

Parameters:

This method accepts two parameters as mentioned above and described below:

  • locales: This parameter is an array of locale strings that contain one or more language or locale tags. Note that it is an optional parameter. If you want to use a specific format of the language in your application then specify that language in the locales argument.
  • Options: It is also an optional parameter and contains properties that specify comparison options. Some properties are localeMatcher, timeZone, weekday, year, month, day, hour, minute, second, etc.

Return values:

  • It returns date and time as a string value in the specific format that is specified by the locale.

Note: The dateObjshould be a valid Date object.

Example 1: Below is the example of the Date toLocaleString()method.

Output:

Date and Time of apocalypse: 26/10/2020, 12:30:00

Example 2:This code prints the current date and time. Also, In this code toLocaleString()method does not use any parameter so it uses the operating system’s locale’s conventions and returns a result that is machine-specific.

Output:

date and time as a string = 1/9/2023, 1:17:10 PM

Example 3:This code prints the date and time in string format specified by the locale parameter.

Output:

6/26/2018, 12:30:00 PM
6/26/2018, 12:30:00

Note: The toLocaleString()method is different from toLocaleDateString()as toLocaleDateString()converts only the date of a Date object into a string but toLocaleString()converts date and time to a string.

We have a complete list of Javascript Date methods, to check those please go through the Javascript Date Object Complete Reference article.

Supported Browsers:

The browsers supported by JavaScript Date toLocaleString() Methodare listed below:

  • Google Chrome
  • Edge
  • Firefox
  • Opera
  • Safari
Comment