이 번역은 완료되지 않았습니다. 이 문서를 번역해 주세요.

Intl.DateTimeFormat 객체는 언어에 민감한 날짜 및 시간 서식을 사용하도록 설정하는 객체의 생성자입니다.

Syntax

new Intl.DateTimeFormat([locales[, options]])
Intl.DateTimeFormat.call(this[, locales[, options]])

Parameters

locales

선택적 요소입니다. BCP 47 언어 태그가 있는 문자열 또는 이러한 문자열의 배열입니다. locales 인수에 대한 일반적인 형식과 해석은, Intl page을 참조하십시오. 다음과 같은 유니코드 확장 키가 허용됩니다:

nu
넘버링 시스템입니다. 가능한 값은 다음과 같습니다: "arab", "arabext", "bali", "beng", "deva", "fullwide", "gujr", "guru", "hanidec", "khmr", "knda", "laoo", "latn", "limb", "mlym", "mong", "mymr", "orya", "tamldec", "telu", "thai", "tibt".
ca
달력입니다. 가능한 값은 다음과 같습니다: "buddhist", "chinese", "coptic", "ethioaa", "ethiopic", "gregory", "hebrew", "indian", "islamic", "islamicc", "iso8601", "japanese", "persian", "roc".
hc
시간 사이클 입니다. 가능한 값은 다음과 같습니다: "h11", "h12", "h23", "h24".
options

선택적 요소입니다. 다음의 프로퍼티의 일부 또는 전부를 가지는 객체:

localeMatcher
사용할 로컬 일치 알고리즘. 가능한 값은 "lookup" 과 "best fit"입니다; 기본값은 "best fit"입니다. 이 옵션에 대한 더욱 많은 정보를 원하시면, Intl page를 보세요.
timeZone
사용할 시간대 입니다. 유일하게 구현된 값이 "UTC" 인지 인식해야합니다; 기본값은 런타임의 기본 시간대입니다. 구현된 것들은 "Asia/Shanghai", "Asia/Kolkata", "America/New_York" 과 같은 IANA time zone database 이름을 인식할 수도 있습니다.
hour12
12 시간 단위의 사용여부 입니다(24 시간 단위 사용의 반대). 사용 가능한 값은 true 와 false 입니다; 기본값은 로컬에 따라 다릅니다. 이 옵션은 hc 언어 태그 및/또는 두 옵션이 모두 있는 경우 hourCycle 옵션보다 우선합니다.
hourCycle
사용할 시간주기 입니다. 가능한 값은 "h11", "h12", "h23""h24"가 있습니다. 이 옵션은 hc 언어 태그를 무시하고, 두 옵션이 모두 지정된 경우 hour12 옵션이 우선합니다.
formatMatcher
사용할 형식 일치 알고리즘입니다. 가능한 값은 "basic" 과 "best fit"가 있습니다; 기본 값은 "best fit"입니다. 이 등록 정보의 사용에 대한 내용은 다음 단락을 참조하세요.

다음 등록 정보는 형식화 된 출력 및 원하는 표현에서 사용할 날짜 / 시간 구성 요소를 설명합니다. 구현은 적어도 다음 하위 내용들을 지원해야 합니다:

  • weekday, year, month, day, hour, minute, second
  • weekday, year, month, day
  • year, month, day
  • year, month
  • month, day
  • hour, minute, second
  • hour, minute

Implementations may support other subsets, and requests will be negotiated against all available subset-representation combinations to find the best match. Two algorithms are available for this negotiation and selected by the formatMatcher property: A fully specified "basic" algorithm and an implementation-dependent "best fit" algorithm.

weekday
The representation of the weekday. Possible values are "narrow", "short", "long".
era
The representation of the era. Possible values are "narrow", "short", "long".
year
The representation of the year. Possible values are "numeric", "2-digit".
month
The representation of the month. Possible values are "numeric", "2-digit", "narrow", "short", "long".
day
The representation of the day. Possible values are "numeric", "2-digit".
hour
The representation of the hour. Possible values are "numeric", "2-digit".
minute
The representation of the minute. Possible values are "numeric", "2-digit".
second
The representation of the second. Possible values are "numeric", "2-digit".
timeZoneName
The representation of the time zone name. Possible values are "short", "long".

The default value for each date-time component property is undefined, but if all component properties are undefined, then year, month, and day are assumed to be "numeric".

Description

Properties

Intl.DateTimeFormat.prototype
Allows the addition of properties to all objects.

Methods

Intl.DateTimeFormat.supportedLocalesOf()
Returns an array containing those of the provided locales that are supported without having to fall back to the runtime's default locale.

DateTimeFormat instances

Properties

DateTimeFormat instances inherit the following properties from their prototype:

Intl.DateTimeFormat.prototype.constructor
A reference to Intl.DateTimeFormat.
Intl.DateTimeFormat.prototype.format
Getter; returns a function that formats a date according to the locale and formatting options of this DateTimeFormat object.

Methods

DateTimeFormat instances inherit the following methods from their prototype:

Intl.DateTimeFormat.prototype.formatToParts()
Returns an Array of objects representing the date string in parts that can be used for custom locale-aware formatting.
Intl.DateTimeFormat.prototype.resolvedOptions()
Returns a new object with properties reflecting the locale and formatting options computed during initialization of the object.

Examples

Using DateTimeFormat

In basic use without specifying a locale, DateTimeFormat uses the default locale and default options.

var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));

// toLocaleString without arguments depends on the implementation,
// the default locale, and the default time zone
console.log(new Intl.DateTimeFormat().format(date));
// → "12/19/2012" if run with en-US locale (language) and time zone America/Los_Angeles (UTC-0800)

Using locales

This example shows some of the variations in localized date and time formats. In order to get the format of the language used in the user interface of your application, make sure to specify that language (and possibly some fallback languages) using the locales argument:

var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));

// Results below use the time zone of America/Los_Angeles (UTC-0800, Pacific Standard Time)

// US English uses month-day-year order
console.log(new Intl.DateTimeFormat('en-US').format(date));
// → "12/19/2012"

// British English uses day-month-year order
console.log(new Intl.DateTimeFormat('en-GB').format(date));
// → "19/12/2012"

// Korean uses year-month-day order
console.log(new Intl.DateTimeFormat('ko-KR').format(date));
// → "2012. 12. 19."

// Arabic in most Arabic speaking countries uses real Arabic digits
console.log(new Intl.DateTimeFormat('ar-EG').format(date));
// → "١٩‏/١٢‏/٢٠١٢"

// for Japanese, applications may want to use the Japanese calendar,
// where 2012 was the year 24 of the Heisei era
console.log(new Intl.DateTimeFormat('ja-JP-u-ca-japanese').format(date));
// → "24/12/19"

// when requesting a language that may not be supported, such as
// Balinese, include a fallback language, in this case Indonesian
console.log(new Intl.DateTimeFormat(['ban', 'id']).format(date));
// → "19/12/2012"

Using options

The date and time formats can be customized using the options argument:

var date = new Date(Date.UTC(2012, 11, 20, 3, 0, 0));

// request a weekday along with a long date
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
console.log(new Intl.DateTimeFormat('de-DE', options).format(date));
// → "Donnerstag, 20. Dezember 2012"

// an application may want to use UTC and make that visible
options.timeZone = 'UTC';
options.timeZoneName = 'short';
console.log(new Intl.DateTimeFormat('en-US', options).format(date));
// → "Thursday, December 20, 2012, GMT"

// sometimes you want to be more precise
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"

// sometimes even the US needs 24-hour time
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"

Specifications

Specification Status Comment
ECMAScript Internationalization API 1.0 (ECMA-402)
The definition of 'Intl.DateTimeFormat' in that specification.
Standard Initial definition.
ECMAScript Internationalization API 2.0 (ECMA-402)
The definition of 'Intl.DateTimeFormat' in that specification.
Standard  
ECMAScript Internationalization API 4.0 (ECMA-402)
The definition of 'Intl.DateTimeFormat' in that specification.
Draft  

Browser compatibility

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung InternetNode.js
Basic supportChrome Full support 24Edge Full support YesFirefox Full support 29IE Full support 11Opera Full support 15Safari Full support 10WebView Android No support NoChrome Android Full support 26Edge Mobile Full support YesFirefox Android Full support 56Opera Android ? Safari iOS Full support 10Samsung Internet Android Full support Yesnodejs ?
IANA time zone names in timeZone optionChrome Full support 24Edge ? Firefox Full support 52IE ? Opera Full support 15Safari Full support 10WebView Android ? Chrome Android Full support 26Edge Mobile ? Firefox Android Full support 56Opera Android ? Safari iOS Full support 10Samsung Internet Android Full support Yesnodejs ?
hourCycleChrome ? Edge Full support YesFirefox Full support 58IE ? Opera ? Safari ? WebView Android ? Chrome Android ? Edge Mobile ? Firefox Android Full support 58Opera Android ? Safari iOS ? Samsung Internet Android ? nodejs ?
prototypeChrome Full support 24Edge Full support YesFirefox Full support 29IE Full support 11Opera Full support 15Safari Full support 10WebView Android No support NoChrome Android Full support 26Edge Mobile Full support YesFirefox Android Full support 56Opera Android ? Safari iOS Full support 10Samsung Internet Android Full support Yesnodejs ?
formatChrome Full support 24Edge Full support 12Firefox Full support 29IE Full support 11Opera Full support 15Safari Full support 10WebView Android No support NoChrome Android Full support 26Edge Mobile Full support YesFirefox Android Full support 56Opera Android ? Safari iOS Full support 10Samsung Internet Android Full support Yesnodejs ?
formatToPartsChrome Full support 57
Full support 57
No support 55 — 60
Disabled
Disabled From version 55 until version 60 (exclusive): this feature is behind the --datetime-format-to-parts runtime flag.
Edge Full support YesFirefox Full support 51IE No support NoOpera Full support YesSafari Full support 11WebView Android Full support YesChrome Android Full support 57Edge Mobile No support NoFirefox Android Full support 56Opera Android No support NoSafari iOS Full support 11Samsung Internet Android Full support 7.0nodejs Full support Yes
resolvedOptionsChrome Full support 24Edge Full support 12Firefox Full support 29IE Full support 11Opera Full support 15Safari Full support 10WebView Android No support NoChrome Android Full support 26Edge Mobile Full support YesFirefox Android Full support 56Opera Android ? Safari iOS Full support 10Samsung Internet Android Full support Yesnodejs ?
supportedLocalesOfChrome Full support 24Edge Full support YesFirefox Full support 29IE Full support 11Opera Full support 15Safari Full support 10WebView Android No support NoChrome Android Full support 26Edge Mobile Full support YesFirefox Android Full support 56Opera Android ? Safari iOS Full support 10Samsung Internet Android Full support Yesnodejs ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
User must explicitly enable this feature.
User must explicitly enable this feature.

See also

문서 태그 및 공헌자

이 페이지의 공헌자: SSJ-unclear
최종 변경자: SSJ-unclear,