intl-datetimeformat
v1.0.0
Published
Simplified Intl.DateTimeFormat formatters.
Downloads
18
Readme
intl-datetimeformat
A simple wrapper around Intl.DateTimeFormat
.
Install
npm install intl-datetimeformat
Use
import { createFormat } from "intl-datetimeformat"
const format = createFormat("en", { dateStyle: "medium", timeStyle: "medium" })
const str = format(date) // date can be a Date object, timestamp, or ISO string.
Reuse locale
import { createPartial } from "intl-datetimeformat"
// Format dates in German.
const createFormat = createPartial("de")
const format = createFormat({ dateStyle: "medium", timeStyle: "medium" })
const str = format(date)