1.0.1 • Published 5 years ago
intl-date-time v1.0.1
Intl.DateTime
A tiny wrapper around the native Intl.DateTimeFormat, with predefined formats.
Table of Contents
Features
- 🎉 Uses native the
Intl.DateTimeFormat
API. - 🚀 Zero dependencies, super tiny.
- 💪 Written in TypeScript.
Installation
npm install --save intl-date-time
Usage
import { format } from 'intl-date-time';
format(date, 'mediumDate');
// Aug 1, 2020
format(date, 'shortTime');
// 6:32 PM
Alternatively, you can get the format options for manual use.
import { getOptions } from 'intl-date-time';
const options = getOptions('longDate');
new Intl.DateTimeFormat('en-US').format(date, options);
// August 1, 2020
Formats
Format | Example |
---|---|
short | 08/1/20, 6:32 PM |
medium | Aug 1, 2020, 6:32:21 PM |
long | August 1, 2020, 6:32:21 PM PDT |
full | Saturday, August 1, 2020, 6:32:21 PM PDT |
shortDate | 08/1/20 |
mediumDate | Aug 1, 2020 |
longDate | August 1, 2020 |
fullDate | Saturday, August 1, 2020 |
shortTime | 6:32 PM |
mediumTime | 6:32:21 PM |
longTime | 6:32:21 PM PDT |
Development
npm install
npm run build