2.0.2 • Published 4 years ago

iso-date-formatter v2.0.2

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

ISO Date Formatter

npm module dependencies MIT License

Installation

npm install iso-date-formatter --save

Usage

import ISODateFormatter from 'iso-date-formatter';

const isoDate = '2019-06-04T14:03:07.007Z';
const formattedDate = ISODateFormatter(isoDate, { format: 'dd MM yyyy HH:mm' }); // => 04 06 2019 14:03

Options

The second parameter is the options object:

OptionTypeDefaultDescription
formatStringdd MM yyyy HH:mm:ssA string which consists of any symbols and tokens. Tokens will be changed by corresponding value from the input string in ISO format.
namedMonthsArrayresult of MMAn array of named months e.g ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] which is used if token MMM is provided in format option

Tokens

Examples below given for 2019-06-04T14:03:07.007Z

NameDescriptionExample
yyyyfour-digit year2019
yytwo-digit year19
MMMmonth from namedMonths optionJun
MMmonth as an padded number06
Mmonth as an unpadded number6
ddday of the month, padded to 204
dday of the month, no padding4
HHhour in 24-hour time, padded to 214
Hhour in 24-hour time, no padding14
hhhour in 12-hour time, padded to 202
hhour in 12-hour time, no padding2
mmminute, padded to 203
mminute, no padding3
sssecond, padded to 2 padding07
ssecond, no padding7
SSSmillisecond, padded to 3007
2.0.2

4 years ago

2.0.1

5 years ago

2.0.0

5 years ago

1.0.0

5 years ago