How a Naive Datetime Bug Showed Wrong Dates to Users in Eastern Timezones
A developer building RealFeedApp discovered that some users were seeing incorrect dates on their daily digest — off by one day depending on how far east of the server they were located. The root cause was the use of Python's datetime.now(), which generated a timezone-unaware timestamp based on the server's local time. When users in eastern timezones received this timestamp, their local date had already crossed midnight, making the digest appear misdated. The fix was straightforward: switching to datetime.now(timezone.utc) so all timestamps are stored and transmitted in UTC, with timezone conversion handled on the client side at display time. The developer noted that two days of debugging were spent investigating the wrong component — the digest generation job — before realising the timestamp itself was never wrong, only misread without its original context.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in