Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

258
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda