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

255
Views
How to get current time in hh:mm:ss format using moment in React JS

I want to calculate the time between hours and moments. with example:

export const DataCoba: React.FC = () => {
const format = "hh:mm:ss";
  return (
    <div>
      {moment(format).isBetween(
        moment("21:00:00", format),
        moment("23:00:00", format)
      )
        ? "Between"
        : "NOOO"}
    </div>
  );
};

from the script above what I want is to get the current time, but only in hh:mm:ss format only. for example: moment('23:00:00', hh:mm:ss).

moment(format) is showing invalid date. Is there a way to do it?

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Delete your first moment's parameter. Because actually your second and third moment is have the same day as your first moment.

Try this one:

export const DataCoba: React.FC = () => {
const format = "hh:mm:ss";
  return (
    <div>
      {moment().isBetween(
        moment("21:00:00", format),
        moment("23:00:00", format)
      )
        ? "Between"
        : "NOOO"}
    </div>
  );
};
about 4 years ago · Juan Pablo Isaza Report

0

This is my expected answer from @TimLewis

moment().isBetween(moment().set('hour', 21), moment().set('hour', 23)) ? 'Yes' : 'No'
about 4 years ago · Juan Pablo Isaza Report
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!