toLocaleString()

ES1+

Returns a string with a language-sensitive representation of this date.

Syntax

date.toLocaleString(locales, options)

Parameters

locales string | Array optional

A string with a BCP 47 language tag, or an array of such strings

options Object optional

An object with configuration properties

Return Value

string

A string representing the date

Examples

JavaScript
const date = new Date('2024-01-15T14:30:00');
console.log(date.toLocaleString('ko-KR'));
console.log(date.toLocaleString('en-US'));
console.log(date.toLocaleString('ja-JP'));
Output:
// '2024. 1. 15. 오후 2:30:00' '1/15/2024, 2:30:00 PM' '2024/1/15 14:30:00'

Related Methods