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

166
Views
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
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!