Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

277
Views
How to start Countdown timer in moment js React

I am new to this using moment js, I took this sample from the internet and modified it according to my way, Here I want the countdown to start from 2 min: 00 sec to 00:00.

import React, { useEffect, useState } from "react";
import moment from "moment";

export default function CountdownMonths(){
  const [currentTime, setCurrentTime] = useState(moment());
  const timeBetween = moment.duration({
    "minutes": 2,
    "seconds":"00"
  });



  useEffect(() => {
    const interval = setInterval(() => {
      setCurrentTime(moment());
    }, 1000);

    return () => clearInterval(interval);
  }, []);

  return (
    <>
      <p>Deadline comes in</p>
      <p className="counter">
        <span>{timeBetween.minutes()}m: </span>
        <span>{timeBetween.seconds()}s </span>
      </p>
    </>
  );
};

How shall I start the countdown on page render? Any help would be much appreciated.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!