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

91
Views
Countdown Banner in different timezones

I currently live in Europe and I work for an American client. Long story short, they have asked me to create a countdown banner for Mother's day coming up, and I am having a little bit of an issue making this countdown banner end time synchronous for the different timezones of the U.S.

const currentTime = new Date().getTime(); // Returning current time in miliseconds
const endDate = new Date('May 3, 2022 23:59:59').getTime(); // This returns the endDate in miliseconds

I'm not sure how to handle the endDate so that it returns the correct endDate whether the user is in Texas or El Paso or wherever. The endDate always needs to be May 3 of 2022

Thank you!

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

0

Your timer should already be consistent across timezones as long as this JavaScript code is client-side. You constructed your endDate with a dateString without a time zone offset, so it is interpreted as the user's local time, and then stored as the number of milliseconds between January 1 1970 00:00:00 UTC and your endDate. The currentDate is also stored in the same way, so the time zone conversion is already handled. You can test this in Chrome DevTools with the Sensors tab by changing your location and verifying that the countdown timer is consistent, i.e. the difference in the countdown timer between two locations should be equal to the difference in their timezone offsets. For example, New York is 3 hours ahead of Los Angeles, so the countdown timer for New York should be -3 hours compared to the timer for Los Angeles.

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!