Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is this something you think they can or should fix?


Been a while since I've looked at available APIs, but can't the browser handle conversions into its own local system TZ?

If it's going by IP geolocation, I would call that a bug.


Browsers can handle conversions just fine but they need some context. If that context is somehow tampered with, then the results might be weird.

In this case, SpaceX seems to be using UNIX timestamps(1) which is probably fed to a combination of Date and Intl to obtain a localized date string. Extrapolating the country where the user is located is not really rocket science either. But, if my context is somehow tampered with (VPN, internal clock, browser settings…), then I will get a potentially "wrong" date, for whatever definition of "wrong".

The problem is fundamentally the same on the server side because you can only rely on the information you get… which might be wrong.

So either you take the safest route, which is to display the local time of the organization or its UTC representation and let visitors figure out their local date on their own, or you take a somewhat riskier one, which is to try to display a localized date to your users and accept the potential flaws of the method.

[1] https://sxcontent9668.azureedge.us/cms-assets/future_mission...


it's way easier too. Just parse an ISO UTC date string into a javascript date object and it'll correctly display the local time, no conversion needed.


Yes, by setting the datetime attribute (in UTC) on a time element, then on the client side pulling that into a Date object and calling toLocaleString().


Absolutely. If they sent UTC over the wire and handled it client-side, it would just work (your browser tends to know its own timezone)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: