Timezone Mismatch Caused Daily Sales Report to Misplace Orders, Developer Explains
A developer found that a daily sales report running on Laravel was consistently missing a few orders each morning, because they were counted under the previous day. The orders placed between midnight and 03:00 local time were being bucketed incorrectly since the server operated in UTC while the business ran on UTC+3. The root cause was that the query used UTC-based date functions and whereDate(), which compares the stored UTC date and can also prevent efficient index use. The article recommends keeping the app timezone as UTC, pinning the MySQL session to +00:00, and converting local calendar days into half-open UTC ranges in PHP. This approach also correctly handles daylight saving time transitions, such as the 25-hour day in Berlin on 25 October 2026.
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