Determine time zone of client browser

How can I determine the time zone of the client browser from the server side javascript?

date.getTimezoneOffset() returns 0

Intl.DateTimeFormat().resolvedOptions().timeZone; will return a variable like Europe/Istanbul.

1 Like

My code is running on the server. I tried your idea. It just returns UTC.

HTTP requests don’t include any timezone information (which is probably a good thing, because, y’know, fingerprinting and stuff). Your best bet is to figure out the timezone on the client’s end (via JS or by asking the user which might be the most sensible approach!), and send it along with whatever request you’re sending, for instance by putting it in a cookie.

Alternatively, fastly’s compute@edge allows you to use it’s geolocation service to figure out timezones - you can ask to join the community testing group if you’re interested in this but that’s definitely overkill.

Perhaps also consider if this is actually something you need to do.

3 Likes

OK. Thank you.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.