UNPKG

1.35 kBMarkdownView Raw
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
7Yet 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
16Install it with NPM
17
18```
19npm 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
36Token | Description | Example
37------------ | ------------- | -------------
38Y | 2 or 4 digit year | 2018 or 18
39YYYY | 4 digit year | 2018
40YY | 2 digit year | 18
41M | month | 9
42MM | 2 digit month | 09
43D | day | 3
44DD | 2 digit day | 03
45H | hour | 4
46HH | 2 digit hour | 04
47m | minutes | 8
48mm | 2 digit minutes | 08
49s | seconds | 7
50ss | 2 digit seconds | 07
51S | miliseconds | 1 or 01 or 001
52SS | 2 digit miliseconds | 02
53SSS | 3 digit miliseconds | 003
54
55
56## License
57
58[MIT](https://tldrlegal.com/license/mit-license)
59