This proposal adds two options to Intl.DateTimeFormat
: dateStyle
and timeStyle
. These options give a compact way to request the appropriate, locale-specific way to ask for a date and time of given lengths.
Current Stage:
- Stage 4
Spec Text:
- Zibi Braniecki (@zbraniecki)
- Frank Tang (@FrankYFTang)
- Nathan Hammond (@nathanhammond)
This proposal is based on the CLDR Date/Time Patterns:
- http://cldr.unicode.org/translation/date-time-patterns#TOC-Basic-Time-Formats
- http://cldr.unicode.org/translation/date-time-patterns#TOC-Basic-Date-Formats
- http://unicode.org/reports/tr35/tr35-dates.html
let o = new Intl.DateTimeFormat("en" , {
timeStyle: "short"
});
console.log(o.format(Date.now())); // "13:31"
let o = new Intl.DateTimeFormat("en" , {
dateStyle: "short"
});
console.log(o.format(Date.now())); // "21.03.2012"
let o = new Intl.DateTimeFormat("en" , {
timeStyle: "medium",
dateStyle: "short"
});
console.log(o.format(Date.now())); // "21.03.2012, 13:31"
npm install
npm run build
open index.html