Format your date or time in React js using Moment js

Manish Mandal
How To React
Published in
1 min readJul 27, 2020

Today in this tutorial I'll help you in formatting your date or time in React js. For this, we’ll be using a library called moment js.

A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.

Requirements

  1. Open your project directory and install moment js.
npm i moment --save

2. Open app.js file and import moment from moment.

import moment from 'moment'

3. Now all you need is to pass your timestamp or date format to the moment method.

moment('timestamp').format('MMMM Do YYYY')Example : moment('20010704T120854').format('MMMM Do YYYY')

Below are the Github repository and live code for reference.

--

--

Manish Mandal
How To React

Full Stack Developer | React JS | Next JS | Node JS | Vue JS | Wordpress. Connect with me https://www.linkedin.com/in/manishmandal21/