Hi Friends đź‘‹,
Welcome To Infinitbility! ❤️
To get month name in moment js, use the moment().format()
method by passing desire month format string parameters.
Just import moment in your file and invoke moment().format('MMM');
it will show the current date time with the format.
1moment().format('MMM')
Today, I’m going to show How do I get month from date using moment js, here I will use the momentjs standard method format()
to find month name from the date object.
Let’s start today’s tutorial How do you get month from date using moment js?
Table of content
- Installation
- Example in reactjs
Installation
Use the below installation command as per your package manager, moment support npm, Yarn, NuGet, spm, and meteor.
1npm install moment --save # npm2yarn add moment # Yarn3Install-Package Moment.js # NuGet4spm install moment --save # spm5meteor add momentjs:moment # meteor
Example in reactjs
In the following example, we are going to do
- import the moment package
- example of current date time to get month name
- example of custom date time format to get month name
let’s write the code.
1import moment from "moment";23function App() {4 return (5 <div>6 {/* example of current date time to get month name*/}7 {console.log(moment().format("MMM"))}8 {console.log("----")}9 {/* example of custom date time format to get month name */}10 {console.log(moment('2016-10-08 10:29:23').format("MMM"))}11 </div>12 );13}1415export default App;
TIP: use .format(“MM”) to get current month number.
In the above program, we call moment().format()
with format string rules and console month name from date object.
let’s check the output.

I hope it’s help you, All the best 👍.
Follow me on Twitter
Join our email list and get notified about new content
No worries, I respect your privacy and I will never abuse your email.
Every week, on Tuesday, you will receive a list of free tutorials I made during the week (I write one every day) and news on other training products I create.