Formatting Dates in Create React App with MomentJS
While working with React, I found I wanted a way to work with dates similiar to the way Angular uses the DatePipe to handle displaying dates correctly. The answer is in using the momentjs library.
To do so, add the package to your project:
Then add the following code to test in one of your .js
or .tsx
files:
You should see an ISO string being displayed. To check on ways you can use the library, check the docs on the page above.