1 | [![Build Status](https://travis-ci.org/rdeak/yadate-converter.svg?branch=master)](https://travis-ci.com/rdeak/yadate-converter)
|
2 | [![Coverage Status](https://coveralls.io/repos/github/rdeak/yadate-converter/badge.svg?branch=master)](https://coveralls.io/github/rdeak/yadate-converter?branch=master)
|
3 | [![install size](https://packagephobia.now.sh/badge?p=yadate-converter)](https://packagephobia.now.sh/result?p=yadate-converter)
|
4 |
|
5 | # yadate-converter
|
6 |
|
7 | Yet another date to string and string to date converter
|
8 |
|
9 | ## Main features
|
10 |
|
11 | * parse formatted string to date
|
12 | * format date to string
|
13 |
|
14 | ## Install
|
15 |
|
16 | Install it with NPM
|
17 |
|
18 | ```
|
19 | npm install yadate-converter --save
|
20 | ```
|
21 |
|
22 | ## Parse
|
23 |
|
24 | ```javascript
|
25 | const date = parseDate('14.05.2018', 'DD.MM.YYYY');
|
26 | ```
|
27 |
|
28 | ## Format
|
29 |
|
30 | ```javascript
|
31 | const str = formatDate(new Date(), 'YYYY-M-D');
|
32 | ```
|
33 |
|
34 | ## Tokens
|
35 |
|
36 | Token | Description | Example
|
37 | ------------ | ------------- | -------------
|
38 | Y | 2 or 4 digit year | 2018 or 18
|
39 | YYYY | 4 digit year | 2018
|
40 | YY | 2 digit year | 18
|
41 | M | month | 9
|
42 | MM | 2 digit month | 09
|
43 | D | day | 3
|
44 | DD | 2 digit day | 03
|
45 | H | hour | 4
|
46 | HH | 2 digit hour | 04
|
47 | m | minutes | 8
|
48 | mm | 2 digit minutes | 08
|
49 | s | seconds | 7
|
50 | ss | 2 digit seconds | 07
|
51 | S | miliseconds | 1 or 01 or 001
|
52 | SS | 2 digit miliseconds | 02
|
53 | SSS | 3 digit miliseconds | 003
|
54 |
|
55 |
|
56 | ## License
|
57 |
|
58 | [MIT](https://tldrlegal.com/license/mit-license)
|
59 |
|