1.0.1 • Published 4 years ago

@sm-date/date-formatter v1.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Date Formatter

  • A light javascript tool for formatting date.
  • Zero dependency.
  • TypeScript compatible.

Example

DateFormatter.format('%l %j %F %Y', new Date());
// Sunday 12 October 2014

By default, Date Formatter uses the current browser language. You can force a locale like this:

DateFormatter.setLocale('fr-FR');

You can see examples in example directory.

Install it

With NPM

npm install @sm-date/date-formatter --save
import DateFormatter from '@sm-date/date-formatter';

Otherwise

<script src="https://cdn.jsdelivr.net/npm/@sm-date/date-formatter@1.0/dist/date-formatter.js"></script>

Format

CharacterDescriptionExample
%YA full numeric representation of a year, 4 digits2020
%yA two digit representation of a year20
%dDay of the month, 2 digits with leading zeros01 to 31
%lA full textual representation of the day of the weekSunday through Saturday
%DA textual representation of a day, three lettersMon through Sun
%FA full textual representation of a month, such as January or MarchJanuary through December
%MA short textual representation of a month, three lettersJan through Dec
%mNumeric representation of a month, with leading zeros01 through 12
%nNumeric representation of a month, without leading zeros1 through 12
%G24-hour format of an hour without leading zeros0 through 23
%H24-hour format of an hour with leading zeros00 through 23
%iMinutes with leading zeros00 to 59
%sSeconds with leading zeros00 to 59
1.0.1

4 years ago

1.0.0

4 years ago

0.0.1

4 years ago