| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString | [Back] [Original] |
Get to know MDN better
This page was translated from English by the community. Learn more and join the MDN Web Docs community.
This feature is well established and works across many devices and browser versions. Its been available across browsers since 2015 7.
toLocaleString() . Intl.DateTimeFormat API Intl.DateTimeFormat .
const event = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
// British English uses day-month-year order and 24-hour time without AM/PM
console.log(event.toLocaleString("en-GB", { timeZone: "UTC" }));
// Expected output: "20/12/2012, 03:00:00"
// Korean uses year-month-day order and 12-hour time with AM/PM
console.log(event.toLocaleString("ko-KR", { timeZone: "UTC" }));
// Expected output: "2012. 12. 20. 3:00:00"
toLocaleString()
toLocaleString(locales)
toLocaleString(locales, options)
locales, options .
Intl.DateTimeFormat API , Intl.DateTimeFormat() . Intl.DateTimeFormat , .
locales OptionalBCP 47 . Intl.DateTimeFormat() locales .
Intl.DateTimeFormat , .
options Optional . Intl.DateTimeFormat() options . weekday, year, month, day, dayPeriod, hour, minute, second, fractionalSecondDigits undefined, year, month, day, hour, minute, second "numeric" .
Intl.DateTimeFormat .
. Intl.DateTimeFormat() constructor
Intl.DateTimeFormat new Intl.DateTimeFormat(locales, options).format(date) .
, .
const date = new Date(Date.UTC(2012, 11, 12, 3, 0, 0));
// toLocaleString() , ,
console.log(date.toLocaleString());
// "12/11/2012, 7:00:00 PM" en-Us America/Los_Angeles
locales, options . RangeError .
function toLocaleStringSupportsLocales() {
try {
new Date().toLocaleString("i");
} catch (e) {
return e.name === "RangeError";
}
return false;
}
. ( ) , locales .
const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
//
// America/Los_Angeles for the US
// -- AM/PM 12
console.log(date.toLocaleString("en-US"));
// "12/19/2012, 7:00:00 PM"
// -- AM/PM 24
console.log(date.toLocaleString("en-GB"));
// "20/12/2012 03:00:00"
// -- AM/PM 12
console.log(date.toLocaleString("ko-KR"));
// "2012. 12. 20. 12:00:00"
//
console.log(date.toLocaleString("ar-EG"));
// "// :: "
// ,
// 2012 Heisei 24
console.log(date.toLocaleString("ja-JP-u-ca-japanese"));
// "24/12/20 12:00:00"
// , . ( )
console.log(date.toLocaleString(["ban", "id"]));
// "20/12/2012 11.00.00"
toLocaleString() options .
const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
// Request a weekday along with a long date
const options = {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric",
};
console.log(date.toLocaleString("de-DE", options));
// "Donnerstag, 20. Dezember 2012"
// UTC .
options.timeZone = "UTC";
options.timeZoneName = "short";
console.log(date.toLocaleString("en-US", options));
// "Thursday, December 20, 2012, GMT"
// en-US 24
console.log(date.toLocaleString("en-US", { hour12: false }));
// "12/19/2012, 19:00:00"
, toLocaleString() . , ; .
IE Edge , .
, toLocaleString() .
"1/1/2019, 01:00:00" ===
new Date("2019-01-01T01:00:00Z").toLocaleString("en-US");
// Firefox true
// IE Edge false
: See also this StackOverflow thread for more details and examples.
| Specification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-date.prototype.tolocalestring |
| ECMAScript 2027 Internationalization API Specification # sup-date.prototype.tolocalestring |
Intl.DateTimeFormatDate.prototype.toLocaleDateString()Date.prototype.toLocaleTimeString()Date.prototype.toString()This page was last modified on 2026 7 15 by MDN contributors.
DateDate.prototype.getDate()Date.prototype.getDay()Date.prototype.getFullYear()Date.prototype.getHours()Date.prototype.getMilliseconds()Date.prototype.getMinutes()Date.prototype.getMonth()Date.prototype.getSeconds()Date.prototype.getTime()Date.prototype.getTimezoneOffset()Date.prototype.getUTCDate()Date.prototype.getUTCDay()Date.prototype.getUTCFullYear()Date.prototype.getUTCHours()Date.prototype.getUTCMilliseconds()Date.prototype.getUTCMinutes()Date.prototype.getUTCMonth()Date.prototype.getUTCSeconds()Date.prototype.getYear()Date.prototype.setDate()Date.prototype.setFullYear()Date.prototype.setHours()Date.prototype.setMilliseconds()Date.prototype.setMinutes()Date.prototype.setMonth()Date.prototype.setSeconds()Date.prototype.setTime()Date.prototype.setUTCDate()Date.prototype.setUTCFullYear()Date.prototype.setUTCHours()Date.prototype.setUTCMilliseconds()Date.prototype.setUTCMinutes()Date.prototype.setUTCMonth()Date.prototype.setUTCSeconds()Date.prototype.setYear()Date.prototype.toDateString()Date.prototype.toISOString()Date.prototype.toJSON()Date.prototype.toLocaleDateString()Date.prototype.toLocaleString()Date.prototype.toLocaleTimeString()Date.prototype.toString()toTemporalInstant()Date.prototype.toTimeString()Date.prototype.toUTCString()Date.prototype.valueOf()Date.prototype[@@toPrimitive]Object/FunctionObject.prototype.__defineGetter__()Object.prototype.__defineSetter__()Object.prototype.__lookupGetter__()Object.prototype.__lookupSetter__()Object.prototype.hasOwnProperty()Object.prototype.isPrototypeOf()Object.prototype.propertyIsEnumerable()Object.prototype.toLocaleString()Object.prototype.toString()Object.prototype.valueOf()Your blueprint for a better internet.
Portions of this content are 19982026 by individual mozilla.org contributors. Content available under a Creative Commons license.
| Web Proxy Viewer | New URL | Original Page |