Hi Friends đź‘‹,
Welcome To Infinitbility! ❤️
To get the current date in moment js, just call moment()
with no parameter, it will return the current date and time.
Just import moment in your file and invoke moment()
.
1moment()
Today, I’m going to show How do I get the current date in moment js, here I will use the momentjs common method moment()
to the current date.
Let’s start the today’s tutorial How do you get the current date in 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
- create a function and console moment
- use moment in react render.
let’s write the code.
1import moment from "moment";23// create a function and console moment4function consoleTheMoment() {5 console.log(moment());6}78function App() {9 consoleTheMoment()10 return (11 <div>12 {/* moment in react render */}13 {moment().toString()}14 </div>15 );16}1718export default App;
Note: If you want to use moment()
in react render, you have to use the toString()
method also to show details in HTML.
In the above program, we call moment()
in a simple function and in react render method to get the current date time using moment.
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.