Why is my database returning the wrong local time for America/Vancouver, America/Edmonton or Africa/Casablanca? #52772
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Queries that convert a timestamp to local time in
America/Vancouver,America/EdmontonorAfrica/Casablancacan return incorrect results on some Supabase Postgres versions. No error is raised. The database returns a local time that differs from the real local time in that zone.Your stored data is not affected, and timestamps stay intact. Only the conversion to local time for the affected zones is wrong.
Overview
What is happening
Some older Supabase Postgres versions ship an outdated
tzdatapackage. Postgres usestzdatato decide the rules for each time zone. The following 2026 time zone changes are affected:America/Vancouver): changed on March 8, 2026.Africa/Casablanca): changed on September 20, 2026.America/Edmonton): changes on November 1, 2026.On affected versions, local-time conversions for these zones, for example
AT TIME ZONE 'America/Vancouver', return incorrect results until you upgrade. This includes the Alberta change on November 1, 2026.Which projects are affected
Projects on a version lower than 15.19.0.003 (Postgres 15) or 17.11.0.003 (Postgres 17). To check your version, open your project's Service Version settings under Project Settings > General.
Diagnose the problem
Option 1: Check your project version
Option 2: Compare a conversion with the real local time
Run the following SQL using the SQL Editor in the Supabase Dashboard. Replace the time zone with one that you use.
Compare the result with the actual current local time in that zone. If they differ, the project is returning incorrect local times for that zone.
Option 3: Contact support
If you are unsure whether your project is affected, open a support ticket and include your project reference.
Find indexes that may hold old values
Only indexes whose definition converts to one of the affected time zones are at risk. An example is
((col AT TIME ZONE 'America/Vancouver')::date). These indexes may hold values computed with the old rules. Indexes on plain columns, including plaintimestamptzcolumns, are not affected, so you do not need to reindex everything.To list candidates, run:
If the query returns no rows, you have no indexes to rebuild.
Solve the problem
Step 1: Upgrade your project
If you use any of the zones above, upgrade your project to the latest version from Project Settings > General > Service Version. The new versions include the updated
tzdatapackage.The upgrade causes downtime, so plan it for a low-traffic window. See the upgrade guide for details.
Step 2: Rebuild affected indexes
After you upgrade, rebuild each index returned by the query above. This does not block reads or writes:
If you skip this step, queries that use those indexes can return results based on the old rules until the indexes are rebuilt.
Confirm the problem is solved
Related topics
All reactions