zlacker

Show HN: A Simple Server to Match Long/Lat to a TimeZone

submitted by ChrisM+(OP) on 2025-05-20 21:43:50 | 50 points 29 comments
[view article] [source] [go to bottom]

I figured this might be useful to folks.

It's a simple PHP server that requires a single-table database (It's fairly "agnostic," but all my uses are in MySQL).

I won't publish any of the servers that I've set up for my apps, because someone is bound to write an application that drives my bandwidth into the stratosphere.

I could definitely take it further, but this gives me all I need for my purposes.

Here's an app I wrote, that uses it: https://apps.apple.com/us/app/we-are-never-alone/id650482602...


NOTE: showing posts with links only show all posts
1. cybera+D1[view] [source] 2025-05-20 21:56:27
>>ChrisM+(OP)
Super nice! I wanted to do an Arduino-based GPS clock that always shows the correct local time, but got bogged down getting the exact timezone boundaries.

Thanks for bringing up https://github.com/evansiroky/timezone-boundary-builder !

2. kevmo3+f2[view] [source] 2025-05-20 22:00:55
>>ChrisM+(OP)
Since the geojson for the timezone data is a static file you can avoid using a database entirely and ship it to your app.

If you'd like to avoid shipping a giant geojson, with the generosity of CDN providers you can actually hit the npm-hosting servers with HTTP Range requests and do this completely on demand from the client: https://github.com/kevmo314/browser-geo-tz

3. akhena+a3[view] [source] 2025-05-20 22:08:07
>>ChrisM+(OP)
Look at this library embedding the TZ data, implemented in multiple languages, even providing an HTTP server https://github.com/ringsaturn/tzf
4. SahAss+r3[view] [source] 2025-05-20 22:09:31
>>ChrisM+(OP)
I'm guessing this does not try to handle things like terra nullius (Bir Tawil, Marie Byrd Land, etc.) or where there might not be a "correct" answer over which timezone is in a place (like https://www.972mag.com/the-worlds-only-ethnic-time-zone/)?
◧◩
5. ChrisM+U3[view] [source] [discussion] 2025-05-20 22:13:37
>>SahAss+r3
It just uses the map that was generated by the TimeZone Boundary Builder[0]. It does fine for my purposes.

I just figured it might be useful. One reason that I wrote it, was because I couldn't find a decent SaaS that didn't charge eye-watering prices, for a fairly slow response. I wrote it in an afternoon or two. Not really an ambitious project.

I don't usually do "Show HN." Not interested in competing with anyone. If you like it, use it. If you don't like it, don't use it. If there are clear bugs, I'm always open to feedback.

[0] https://github.com/evansiroky/timezone-boundary-builder

◧◩◪
9. kevmo3+T8[view] [source] [discussion] 2025-05-20 23:00:40
>>edoceo+78
Good question, the geojson data is actually broken down into two parts, a true JSON file and a quad tree: https://github.com/evansiroky/node-geo-tz/tree/master/data

So I guess it's a bit of a lie that it's only geojson :)

The way it works is you load the index file which contains the large regions (in other words, the first level or two of the quad tree) and if the time zone can't be resolved, it relies on querying the data file which is actually a multi-record protobuf file so you can load the specific range of data you're looking for. The algorithm is here: https://github.com/evansiroky/node-geo-tz/blob/master/src/fi...

Here's the step that resolves individual tree nodes: https://github.com/kevmo314/browser-geo-tz/blob/main/src/fin...

◧◩◪
10. lowerc+Ai[view] [source] [discussion] 2025-05-21 01:00:55
>>ChrisM+U3
FWIW, I'd found https://www.geocod.io/ to be a good service a couple years back. They sponsored some conferences I went to, and I needed some geocoding->timezone info. IIRC, at the time, it was $5/month which covered everything we needed. Dunno if that's eye-watering or not.

Seems to have changed pricing a bit since. The 'pay as you go' model now has 2500 API calls/day for free, and $1/2000 API calls after that. My needs never grew in to needing much more than what we hit for that $5/month, so I can't vouch for their service at a large scale, but I enjoyed using it.

No affiliation just a happy former customer.

◧◩
13. ringsa+xj[view] [source] [discussion] 2025-05-21 01:13:48
>>akhena+a3
Hi, thanks for mentioning. A list of tzf libraries:

- Go: https://github.com/ringsaturn/tzf - Rust: https://github.com/ringsaturn/tzf-rs - Python: https://github.com/ringsaturn/tzfpy - Swift: https://github.com/ringsaturn/tzf-swift - Wasm(browser only): https://github.com/ringsaturn/tzf-wasm - PostgreSQL extension: https://github.com/ringsaturn/pg-tzf

Or online preview: <https://ringsaturn.github.io/tzf-web/>.

Here is a blog post about the packages history: https://blog.ringsaturn.me/en/posts/2023-01-31-history-of-tz...

◧◩
24. ChrisM+2m2[view] [source] [discussion] 2025-05-21 19:29:34
>>jony12+Ne2
That's actually a public domain Wikimedia image. There's an SVG version, which can scale nicely: https://commons.wikimedia.org/wiki/File:World_Time_Zones_Map...
[go to top]