Hacker News new | ask | show | jobs
by sneak 2154 days ago
Is there a good lat/lon to timezone database that lets you leverage this into a presumptive timezone offset from UTC and thus local time?
4 comments

I built something similar for https://ipdata.co. The API will return a time object like this for any IP:

    "time_zone": {
        "name": "America/Chicago",
        "abbr": "CDT",
        "offset": "-0500",
        "is_dst": true,
        "current_time": "2020-07-25T06:10:16.945136-05:00"
    }
Do you need the lat/lon for this? Usually you'd just put in the nearest city.

Moment.js is probably the most prevalent time and date library.

Try https://blip.runway7.net/v2.beta – I've added unix timezone based on the country and state code. The ISO databases have timezones associated with the level 2 code, which roughly corresponds to a state inside a country.
Can’t you just ask the client which timezone it’s in? Every browser knows, and it will be a more accurate answer: the user might be on a foreign VPN or temporarily in another TZ, but not working on that timezone.
My application is not browser-based.

I’d like to set a system clock timezone via geoip only, without location lookup via wifi. On my more secure systems I have location services disabled and it’d be nice to have an accurate local time automatically.

I have a need for this too, and considering making a basic service for it.
https://blip.runway7.net/v2.beta should work for you, let me know if it doesn't?
I actually can’t remember :-/ will fish it out and set up a proper service, maybe paid.
Where is the source code for v2.beta? It’s not on your GitHub.
Hi!

I need to be able to send a lat/long/timestamp to get tinezone.

This is surprisingly difficult task if you need it to work really globally and accurately. You need specific, detailed and uptodate map data for it, and timezones change somewhere in the world all the time. Especially daylight savigs. In 99% of cases you need to find some workaround or limit your task to specific regions, and get something to work in 95% cases
Ah, I haven’t seen a dataset I could use for that. Everything on the links I’m putting up is based on the country and state information.

I’ve seen timezone maps drawn, so this information does exist somewhere, but one would have to draw polygons for each timezone and do coverage checks, which seems complicated. The time zone lines zig and zag a lot.