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

I'll add that timezone information shifts politically over time... It'll never be consistent... your best bet is to ship all dates in UTC as much as possible (which `.toJSON` does) and display in local (which `new Date(jsonstr)` does).

Dates are evil, even in C# with offsets it's not easy... and that's probably the best implementation of dates, with consistent updates I've seen.



> your best bet is to ship all dates in UTC as much as possible (which `.toJSON` does) and display in local (which `new Date(jsonstr)` does).

Goodness yes, I really wish more sites did this. If you're asking a user what their timezone is, you're usually doing it wrong. Send UTC to the client, gracefully upgrade with JS to local time.

This also solves those pesky DD/MM/YY vs MM/DD/YY issues!




Consider applying for YC's Fall 2025 batch! Applications are open till Aug 4

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

Search: