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

183
Views
Creating a countdown with dayjs and unix timestamp, with EST timezone, getting incorrect results

I'm trying to create a countdown using dayjs, with a unix timestamp string, but it has to be according to a specific timezone (in this case its EST), this is my current code:

  //Timestamp - 1645631100000
  const formattedEndTime = dayjs.utc(1645631100000).format();

  const total =
    Date.parse(formattedEndTime) -
    Date.parse(dayjs().tz("America/New_York").format());

  const seconds = Math.floor((total / 1000) % 60);
  const minutes = Math.floor((total / 1000 / 60) % 60);
  const hours = Math.floor((total / (1000 * 60 * 60)) % 24);
  const days = Math.floor(total / (1000 * 60 * 60 * 24));

  return {
    total,
    days,
    hours,
    minutes,
    seconds,
  };

It is not giving me the right result, its always a few hours off, would appreciate any help with this, 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!