1.0.1 • Published 5 years ago

intl-date-time v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

NPM Version CI Dependency Status Dev Dependency Status

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

FormatExample
short08/1/20, 6:32 PM
mediumAug 1, 2020, 6:32:21 PM
longAugust 1, 2020, 6:32:21 PM PDT
fullSaturday, August 1, 2020, 6:32:21 PM PDT
shortDate08/1/20
mediumDateAug 1, 2020
longDateAugust 1, 2020
fullDateSaturday, August 1, 2020
shortTime6:32 PM
mediumTime6:32:21 PM
longTime6:32:21 PM PDT

Development

npm install
npm run build
1.0.1

5 years ago

1.0.0

5 years ago