Laravel MySQL to Postgres: timestamps off by hours after migration (TIMESTAMP time zone shift fix)
TuskShiftNew, free, in your browser: paste your SHOW CREATE TABLE and see what breaks on Postgres (int unsigned overflow, TIMESTAMP shift, _ci collations, sequences, tinyint(1), ENUM/SET, zero dates, FULLTEXT). Nothing is uploaded.
After moving a Laravel app from MySQL to Postgres, created_at and other timestamp values are off by a few hours. Usually by exactly your server's UTC offset: 12:00 has become 17:00 on a US Central server. Row counts match, nothing errors, and datetime columns look fine. This page explains why, how to tell if you're affected, and how to fix the data, including the daylight-saving catch that breaks the obvious fix. Tested 26 Oct 2026 on MariaDB 11.8.6 and PostgreSQL 17.11 with Laravel 13.38. From TuskShift (brand account; written with AI help, every command below was run by hand).
Want the fix scripts ready to run? The Laravel Postgres Error Fix Pack ($19) has tested scripts for this error and five others (sequence reset, TIMESTAMP shift, GROUP BY, boolean = integer, zero dates, unsigned overflow).
Why it happens
MySQL TIMESTAMP columns are stored in UTC and converted to the session time zone when you read them. By default that's the server's zone (@@time_zone = SYSTEM), so your app reads and writes local wall-clock time and everything looks right.
mysqldump and mariadb-dump add SET TIME_ZONE='+00:00' to the top of every dump (the default --tz-utc option), so TIMESTAMP values are exported in UTC. Laravel's timestamps() on pgsql creates timestamp(0) without time zone, which stores whatever string it gets. So the UTC value lands as if it were local time.
What we saw on a server running US Central time:
-- MariaDB, as the app sees it: created_at (TIMESTAMP) 2026-10-26 12:00:00 published_at (DATETIME) 2026-10-26 12:00:00 -- in the dump: (1,'2026-10-26 17:00:00','2026-10-26 12:00:00') -- winter row in the dump: (2,'2026-01-15 18:00:00','2026-01-15 12:00:00')
DATETIME columns aren't converted, so only TIMESTAMP columns shift. That's why it's easy to miss: some times are right and some are wrong.
Are you affected?
On the MySQL side:
SELECT @@global.time_zone, @@system_time_zone; SELECT table_name, column_name FROM information_schema.columns WHERE table_schema = DATABASE() AND data_type = 'timestamp';
If the zone is SYSTEM with a non-UTC system zone (or any non-UTC offset), and you have TIMESTAMP columns, a default dump shifts them. If your server already runs on UTC, the values come across unchanged.
Fix before the load (easiest)
Dump with --skip-tz-utc. The dump then holds server-local times, which is what your app was reading. We checked: the same row exported as 2026-10-26 12:00:00.
Fix after the load: use a named zone, not a fixed offset
If the data is already in Postgres, convert each shifted column from UTC back to the server's zone. Use the zone name so each row gets the offset that applied on its own date:
UPDATE posts SET created_at = (created_at AT TIME ZONE 'UTC') AT TIME ZONE 'America/Chicago';
The trap: created_at - interval '5 hours' looks right for today's rows but is wrong for every row from the other half of the year. On our test data, the October row came back as 12:00 with both fixes, but the January row came back as 13:00 with the fixed offset and 12:00 with the named zone. Run the UPDATE once per column: running it twice shifts the values again. Wrap it in a transaction and spot-check a few rows against MySQL first.
Going forward
If you can, switch these columns to timestampTz() (timestamp with time zone) and keep config('app.timezone') explicit. Then a change in server or session zone no longer changes what's stored.
The other traps that pass row counts
The time-zone shift is one of several things a MySQL to Postgres move gets wrong without any error: sequences left at 1 after the import, "must appear in the GROUP BY clause" errors, case-sensitive LIKE and email logins, unsigned ints over 2,147,483,647, zero dates. The free TuskShift checker v2 (one PHP file, read-only, MIT) lists your TIMESTAMP columns when the session zone isn't UTC, along with the rest, in about two minutes. Also see: fixing "duplicate key value violates unique constraint" after an import.
The paid TuskShift Migration Kit ($49) covers the whole move: 52 code rules, data preflight, resumable copy, per-row checksum verify and a cutover playbook. Code LAUNCH30 takes 30% off until 5 Nov: tuskshift.gumroad.com/l/tuskshift/LAUNCH30.
Not affiliated with Laravel, MySQL, MariaDB or PostgreSQL.
Want the fix scripts ready to run? The Laravel Postgres Error Fix Pack ($19) has tested scripts for this error and five others (sequence reset, TIMESTAMP shift, GROUP BY, boolean = integer, zero dates, unsigned overflow).