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