File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -2821,23 +2821,29 @@ npm install moment --save
2821
2821
2822
2822
* Format Dates
2823
2823
2824
- ``` bash
2824
+ ``` js
2825
+ const moment = require (' moment' );
2826
+
2825
2827
moment ().format (' MMMM Do YYYY, h:mm:ss a' ); // October 24th 2020, 3:15:22 pm
2826
2828
moment ().format (' dddd' ); // Saturday
2827
2829
moment ().format (" MMM Do YY" ); // Oct 24th 20
2828
2830
```
2829
2831
2830
2832
* Relative Time
2831
2833
2832
- ``` bash
2834
+ ``` js
2835
+ const moment = require (' moment' );
2836
+
2833
2837
moment (" 20111031" , " YYYYMMDD" ).fromNow (); // 9 years ago
2834
2838
moment (" 20120620" , " YYYYMMDD" ).fromNow (); // 8 years ago
2835
2839
moment ().startOf (' day' ).fromNow (); // 15 hours ago
2836
2840
```
2837
2841
2838
2842
* Calendar Time
2839
2843
2840
- ``` bash
2844
+ ``` js
2845
+ const moment = require (' moment' );
2846
+
2841
2847
moment ().subtract (10 , ' days' ).calendar (); // 10/14/2020
2842
2848
moment ().subtract (6 , ' days' ).calendar (); // Last Sunday at 3:18 PM
2843
2849
moment ().subtract (3 , ' days' ).calendar (); // Last Wednesday at 3:18 PM
You can’t perform that action at this time.
0 commit comments