| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat | [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 2017 ..
Intl.DateTimeFormat .
const date = new Date(Date.UTC(2020, 11, 20, 3, 23, 16, 738));
// Results below assume UTC timezone - your results may vary
// Specify default date formatting for language (locale)
console.log(new Intl.DateTimeFormat("en-US").format(date));
// Expected output: "12/20/2020"
// Specify default date formatting for language with a fallback language (in this case Indonesian)
console.log(new Intl.DateTimeFormat(["ban", "id"]).format(date));
// Expected output: "20/12/2020"
// Specify date and time format using "style" options (i.e. full, long, medium, short)
console.log(
new Intl.DateTimeFormat("en-GB", {
dateStyle: "full",
timeStyle: "long",
timeZone: "Australia/Sydney",
}).format(date),
);
// Expected output: "Sunday, 20 December 2020 at 14:23:16 GMT+11"
Intl.DateTimeFormat() Intl.DateTimeFormat.
Intl.DateTimeFormat.prototype Intl.DateTimeFormat.
Intl.DateTimeFormat.prototype.constructor-, . Intl.DateTimeFormat Intl.DateTimeFormat.
Intl.DateTimeFormat.prototype[@@toStringTag] @@toStringTag "Intl.DateTimeFormat". Object.prototype.toString().
Intl.DateTimeFormat.prototype.format()-, DateTimeFormat.
Intl.DateTimeFormat.prototype.formatRange()Intl.DateTimeFormat.prototype.formatRangeToParts()Intl.DateTimeFormat.prototype.formatToParts()Intl.DateTimeFormat.prototype.resolvedOptions(), , .
DateTimeFormat DateTimeFormat .
const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
// ,
//
console.log(new Intl.DateTimeFormat().format(date));
// "12/19/2012", en-US America/Los_Angeles
locales . , , , (, , ) locales:
const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));
// ,
// America/Los_Angeles
// --
console.log(new Intl.DateTimeFormat("en-US").format(date));
// "12/19/2012"
// --
console.log(new Intl.DateTimeFormat("en-GB").format(date));
// "20/12/2012"
// --
console.log(new Intl.DateTimeFormat("ko-KR").format(date));
// "2012. 12. 20."
//
console.log(new Intl.DateTimeFormat("ar-EG").format(date));
// "//"
// ,
// 2012 24-
console.log(new Intl.DateTimeFormat("ja-JP-u-ca-japanese").format(date));
// "24/12/20"
// ,
// , ,
console.log(new Intl.DateTimeFormat(["ban", "id"]).format(date));
// "20/12/2012"
options options:
const date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0, 200));
//
let options = {
weekday: "long",
year: "numeric",
month: "long",
day: "numeric",
};
console.log(new Intl.DateTimeFormat("de-DE", options).format(date));
// "Donnerstag, 20. Dezember 2012"
// UTC
options.timeZone = "UTC";
options.timeZoneName = "short";
console.log(new Intl.DateTimeFormat("en-US", options).format(date));
// "Thursday, December 20, 2012, GMT"
//
options = {
hour: "numeric",
minute: "numeric",
second: "numeric",
timeZone: "Australia/Sydney",
timeZoneName: "short",
};
console.log(new Intl.DateTimeFormat("en-AU", options).format(date));
// "2:00:00 pm AEDT"
//
options.fractionalSecondDigits = 3; //
console.log(new Intl.DateTimeFormat("en-AU", options).format(date));
// "2:00:00.200 pm AEDT"
// 24-
options = {
year: "numeric",
month: "numeric",
day: "numeric",
hour: "numeric",
minute: "numeric",
second: "numeric",
hour12: false,
timeZone: "America/Los_Angeles",
};
console.log(new Intl.DateTimeFormat("en-US", options).format(date));
// "12/19/2012, 19:00:00"
// , , undefined
console.log(new Intl.DateTimeFormat(undefined, options).format(date));
// "12/19/2012, 19:00:00"
//
options = { hour: "numeric", dayPeriod: "short" };
console.log(new Intl.DateTimeFormat("en-US", options).format(date));
// 10 at night
options:
const options = { calendar: "chinese", numberingSystem: "arab" };
const dateFormat = new Intl.DateTimeFormat(undefined, options);
const usedOptions = dateFormat.resolvedOptions();
console.log(usedOptions.calendar);
// "chinese"
console.log(usedOptions.numberingSystem);
// "arab"
console.log(usedOptions.timeZone);
// "America/New_York" (the users default timezone)
| Specification |
|---|
| ECMAScript 2027 Internationalization API Specification # datetimeformat-objects |
This page was last modified on 17 . 2025 . by MDN contributors.
Intl.DateTimeFormatObject/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()IntlIntl.CollatorIntl.DisplayNamesIntl.DurationFormatIntl.ListFormatIntl.LocaleIntl.NumberFormatIntl.PluralRulesIntl.RelativeTimeFormatIntl.SegmenterYour 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 |