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

173
Vistas
Why is isBefore() not working with a different timeszone in dayjs()?

I have an expiry date time (expiryDate which is in mysql date time format) which is always in the Mountain Standard time zone. I need to see if we have passed the expiry date in the browser - which may be in a different time zone.

Here is my code:

let expireTimeMountain = new dayjs(expiryDate, 'YYYY-MM-DD HH:mm:ss');
let currentTimeMountain = new dayjs().tz("America/Edmonton");

let expiredFlag = expireTimeMountain.isBefore(currentTimeMountain);

but this does not work. I think the currentTimeMountain is not being processed in the correct time zone.

Here is my debug code:

console.log(expiredFlag);

console.log(expireTimeMountain.format('ddd, MMM D, YYYY h:mm A'));
console.log(currentTimeMountain.format('ddd, MMM D, YYYY h:mm A'));

and this returns:

true
Fri, Feb 25, 2022 9:05 AM
Fri, Feb 25, 2022 8:48 AM

and so my expiry time is 9:05am and the current time is 8:48am, so expiry flag should be false.

Can anyone see my issue? Thanks!

about 4 years ago · Juan Pablo Isaza
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