Skip to content

Commit 4738438

Browse files
committed
Update README.md
1 parent ed6a7b5 commit 4738438

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2821,23 +2821,29 @@ npm install moment --save
28212821

28222822
* Format Dates
28232823

2824-
```bash
2824+
```js
2825+
const moment = require('moment');
2826+
28252827
moment().format('MMMM Do YYYY, h:mm:ss a'); // October 24th 2020, 3:15:22 pm
28262828
moment().format('dddd'); // Saturday
28272829
moment().format("MMM Do YY"); // Oct 24th 20
28282830
```
28292831

28302832
* Relative Time
28312833

2832-
```bash
2834+
```js
2835+
const moment = require('moment');
2836+
28332837
moment("20111031", "YYYYMMDD").fromNow(); // 9 years ago
28342838
moment("20120620", "YYYYMMDD").fromNow(); // 8 years ago
28352839
moment().startOf('day').fromNow(); // 15 hours ago
28362840
```
28372841

28382842
* Calendar Time
28392843

2840-
```bash
2844+
```js
2845+
const moment = require('moment');
2846+
28412847
moment().subtract(10, 'days').calendar(); // 10/14/2020
28422848
moment().subtract(6, 'days').calendar(); // Last Sunday at 3:18 PM
28432849
moment().subtract(3, 'days').calendar(); // Last Wednesday at 3:18 PM

0 commit comments

Comments
 (0)