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

181
Views
JavaScript's time zones as a way to locate a user's country

I need to determine a user's country, and it doesn't need to be super accurate (getting it right 90% of the time is probably enough). I realized the time zone returned by JavaScript could work.

Example:

console.log(Intl.DateTimeFormat().resolvedOptions().timeZone);

Will return America/Toronto or America/New_York, which can help me differentiate a Canadian from an American.

Sure I understand this is based on the user’s preferences, not its real location. But is there a huge pitfall I'm not seeing right now using this technic?

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

0

After some research, turns out it depends on the scenario (was predictable). For my scenarios, American get the right Timezone 95%+ of the time, while Canadian get it 90%+.

The way to test this out was to save the user's JS timezone in our Google Analytics, and then compare it to their location.

So your mileage may vary, but for my use case, this was more than enough.

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!