Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

JavaScript Dictionary

  1. Home
  2. JavaScript Dictionary
  3. Date .toLocaleDateString() / toISOString()

Date .toLocaleDateString() / toISOString()

Methods for converting a Date object to a human-readable string. You can display dates in a locale-specific format or convert to ISO format.

Syntax

// Returns a locale-specific date string.
var str = date.toLocaleDateString();
var str = date.toLocaleDateString(locale, options);

// Returns a locale-specific date and time string.
var str = date.toLocaleString();

// Returns a locale-specific time string.
var str = date.toLocaleTimeString();

// Returns a string in ISO 8601 format.
var str = date.toISOString();

Method List

MethodDescription
date.toLocaleDateString()Returns a locale-specific date string. In a US English environment, this produces a format like "4/15/2025".
date.toLocaleString()Returns a locale-specific date and time string.
date.toLocaleTimeString()Returns a locale-specific time string.
date.toISOString()Returns a string in ISO 8601 format. The time zone is always UTC.
date.toDateString()Returns a short English date string, such as "Tue Apr 15 2025".

Sample Code

var date = new Date(2025, 3, 15, 14, 30, 45); // April 15, 2025, 14:30:45

// Basic conversions
console.log(date.toLocaleDateString()); // Outputs something like "4/15/2025".
console.log(date.toLocaleString()); // Outputs something like "4/15/2025, 2:30:45 PM".
console.log(date.toLocaleTimeString()); // Outputs something like "2:30:45 PM".
console.log(date.toISOString()); // Outputs "2025-04-15T05:30:45.000Z". Converted to UTC.
console.log(date.toDateString()); // Outputs "Tue Apr 15 2025".

// Display the date with a specific locale.
console.log(date.toLocaleDateString("ja-JP")); // Outputs "2025/4/15".
console.log(date.toLocaleDateString("en-US")); // Outputs "4/15/2025".
console.log(date.toLocaleDateString("de-DE")); // Outputs "15.4.2025".

// Use options to control the display format in detail.
var options = {
	year: "numeric",
	month: "long",
	day: "numeric",
	weekday: "long"
};
console.log(date.toLocaleDateString("ja-JP", options)); // Outputs "2025年4月15日火曜日".
console.log(date.toLocaleDateString("en-US", options)); // Outputs "Tuesday, April 15, 2025".

// Specify time formatting options.
var timeOptions = {
	hour: "2-digit",
	minute: "2-digit",
	hour12: false
};
console.log(date.toLocaleTimeString("en-US", timeOptions)); // Outputs "14:30".

Common Options

OptionValuesDescription
year"numeric" / "2-digit"Format for the year. "numeric" displays 4 digits; "2-digit" displays the last 2 digits.
month"numeric" / "2-digit" / "long" / "short"Format for the month. "long" displays the full name (e.g., "April"); "short" displays an abbreviated name (e.g., "Apr").
day"numeric" / "2-digit"Format for the day of the month.
weekday"long" / "short" / "narrow"Format for the day of the week. "long" displays the full name (e.g., "Tuesday"); "short" displays an abbreviated name (e.g., "Tue").
hour / minute / second"numeric" / "2-digit"Format for the hour, minute, and second.
hour12true / falseSpecifies whether to use 12-hour time. Set to false for 24-hour time.

Notes

Choose the appropriate string conversion method based on your use case. When displaying a date to the user, date.toLocaleDateString() is convenient because it respects the user's locale. You can pass a locale string as the first argument and an options object as the second argument to control the output format precisely.

date.toISOString() returns a string in ISO 8601 format, making it suitable for API communication and data storage. Note that the time zone is always converted to UTC — for example, 14:00 in Japan (JST) becomes 05:00 in UTC (9 hours behind).

If you need to build a custom date format, use getter methods such as 'date.getFullYear()'.

Browser Compatibility

Chrome Chrome
49+
Supported in all versions
Firefox Firefox
57+
Supported in all versions
Safari Safari
18+
Supported in all versions
Edge Edge
80+
11 or earlier ×
IE IE
11+
4.5 or earlier ×
Opera Opera
48+
4 or earlier ×
iOS Safari iOS Safari
18+
Supported in all versions
Android Browser Android Browser
37+
4 or earlier ×
Chrome Android Chrome Android
36+
17 or earlier ×
Firefox Android Firefox Android
79+
3 or earlier ×

If you find any errors or copyright issues, please .