Skip to content

Commit ed6a7b5

Browse files
committed
moment
1 parent a757019 commit ed6a7b5

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2807,6 +2807,42 @@ fs.copy('/tmp/myfile', '/tmp/mynewfile', err => {
28072807
})
28082808
```
28092809

2810+
**j) moment**
2811+
2812+
A JavaScript date library for parsing, validating, manipulating, and formatting dates.
2813+
2814+
**Installation**
2815+
2816+
```bash
2817+
npm install moment --save
2818+
```
2819+
2820+
**Usage**
2821+
2822+
* Format Dates
2823+
2824+
```bash
2825+
moment().format('MMMM Do YYYY, h:mm:ss a'); // October 24th 2020, 3:15:22 pm
2826+
moment().format('dddd'); // Saturday
2827+
moment().format("MMM Do YY"); // Oct 24th 20
2828+
```
2829+
2830+
* Relative Time
2831+
2832+
```bash
2833+
moment("20111031", "YYYYMMDD").fromNow(); // 9 years ago
2834+
moment("20120620", "YYYYMMDD").fromNow(); // 8 years ago
2835+
moment().startOf('day').fromNow(); // 15 hours ago
2836+
```
2837+
2838+
* Calendar Time
2839+
2840+
```bash
2841+
moment().subtract(10, 'days').calendar(); // 10/14/2020
2842+
moment().subtract(6, 'days').calendar(); // Last Sunday at 3:18 PM
2843+
moment().subtract(3, 'days').calendar(); // Last Wednesday at 3:18 PM
2844+
```
2845+
28102846
<div align="right">
28112847
<b><a href="#">↥ back to top</a></b>
28122848
</div>

0 commit comments

Comments
 (0)