A MySQL TIMESTAMP column cannot hold a date after January 2038 and changes meaning with each connection’s time zone, so DATETIME filled with UTC by the application is the safer default. TIMESTAMP looks like the more correct type, because MySQL converts it to UTC for you, but it ends in January 2038, it shifts every value with the connection’s time zone, and it refuses some local times outright. The choice matters most on a table that already has data, because converting a column between the two can fail on rows you did not know about or quietly change what every value means.

Everything below ran on MySQL 9.7.4 in a throwaway container, with the default strict sql_mode and the container’s time zone set to UTC.

MySQL DATETIME vs TIMESTAMP: which should you use?

Use DATETIME with the application writing UTC; pick TIMESTAMP only if you want MySQL to convert through each session’s time zone and every date will stay before 2038.

The MySQL manual states both differences in two lines: “MySQL converts TIMESTAMP values from the current time zone to UTC for storage, and back from UTC to the current time zone for retrieval. (This does not occur for other types such as DATETIME.)” and “TIMESTAMP has a range of ‘1970-01-01 00:00:01’ UTC to ‘2038-01-19 03:14:07’ UTC.”

DATETIMETIMESTAMP
Range1000-01-01 to 9999-12-311970-01-01 00:00:01 to 2038-01-19 03:14:07 UTC
StoresThe value as writtenUTC, converted from the session time zone
Read back in another session time zoneUnchangedConverted to that zone
A local time that does not exist (spring-forward gap)StoredRefused (error 1292)
Storage5 bytes, plus up to 3 for fractional seconds4 bytes, plus up to 3
DEFAULT CURRENT_TIMESTAMP and ON UPDATE CURRENT_TIMESTAMPAllowedAllowed
Created byDjango DateTimeField (datetime(6)), Rails datetime and timestamps, Laravel dateTime()Laravel timestamps() and timestamp()

The storage figures are from the manual’s storage requirements page: one byte per column per row is the whole saving. The framework column is from each project’s own source: Django’s MySQL backend maps DateTimeField to datetime(6), Rails’ MySQL adapter maps its datetime type to datetime, and Laravel’s documentation says timestamps() creates “TIMESTAMP equivalent columns”. So a Laravel app on MySQL holds its created_at in the type that ends in 2038, and a Django or Rails app does not.

What does TIMESTAMP do with time zones that DATETIME does not?

TIMESTAMP converts on the way in and on the way out using the session’s time_zone, so the same row reads differently from two connections, while DATETIME returns exactly what was written.

Both columns of one row were set to 2026-11-29 09:00:00 from a session at +07:00, then read back from a session at +00:00:

CREATE TABLE ev (id INT PRIMARY KEY, ts TIMESTAMP NULL, dt DATETIME NULL);
SET time_zone = '+07:00';
INSERT INTO ev VALUES (1, '2026-11-29 09:00:00', '2026-11-29 09:00:00');
SET time_zone = '+00:00';
SELECT ts, dt FROM ev;
-- ts: 2026-11-29 02:00:00   dt: 2026-11-29 09:00:00

That conversion is the appeal of TIMESTAMP, and also its catch: the meaning of every write depends on a setting each connection carries. A connection pool configured with time_zone = 'SYSTEM' on a server whose system zone is not UTC, and +00:00 on another, writes different instants for the same text. With a named zone loaded, daylight saving adds two more surprises. In America/New_York, 2026-03-08 02:30:00 does not exist, and inserting it into the TIMESTAMP failed with Incorrect datetime value while the DATETIME column took it. 2026-11-01 01:30:00 happens twice, and MySQL stored the first of the two, 05:30 UTC, without saying which it picked.

A DATETIME that the application always writes in UTC has none of these problems. The rule moves into the application, which already knows what zone its clock is in. If you need a value’s original zone, store it in its own column; neither type keeps it.

What happens to a TIMESTAMP column after 2038?

It cannot hold the value: anything after ‘2038-01-19 03:14:07’ UTC, or before 1970, fails the statement.

INSERT INTO ev (id, ts) VALUES (2, '2038-01-19 03:14:07');  -- stored
INSERT INTO ev (id, ts) VALUES (3, '2038-01-19 03:14:08');
-- ERROR 1292 (22007): Incorrect datetime value: '2038-01-19 03:14:08' for column 'ts'
INSERT INTO ev (id, ts) VALUES (4, '1965-06-01 00:00:00');
-- ERROR 1292 (22007): Incorrect datetime value: '1965-06-01 00:00:00' for column 'ts'

That is about eleven years away for created_at, but already here for any column that holds a future date: expires_at, valid_until, a contract end, a loan’s last payment. A 15-year subscription sold today ends in 2041 and cannot be stored. Birth dates and historical records fail at the other end. DATETIME takes all of them.

What does converting between TIMESTAMP and DATETIME change?

It rewrites the table either way, and the session time zone decides the result: to DATETIME each stored instant becomes that session’s wall-clock time, and to TIMESTAMP every value outside 1970 to 2038 fails the statement.

Two identical tables held 02:00 UTC in a TIMESTAMP column. Each was converted with the same statement, from sessions in different zones:

SET time_zone = '+00:00';
ALTER TABLE a MODIFY ts DATETIME NULL;   -- a.ts: 2026-11-29 02:00:00
SET time_zone = '+07:00';
ALTER TABLE b MODIFY ts DATETIME NULL;   -- b.ts: 2026-11-29 09:00:00

Nothing failed and nothing warned. If the migration tool’s connection uses the server’s SYSTEM zone and the server is not in UTC, every converted value is shifted by that offset, and only a reader who compares them with another column notices. Set the session to UTC before the ALTER.

The other direction fails instead of shifting. Converting a DATETIME column that held 2040-01-01 to TIMESTAMP stopped with error 1292 on that row, and MySQL rolled the ALTER back, leaving the column a DATETIME. Either way it is a full table copy: ALGORITHM=INPLACE was refused (“Cannot change column type INPLACE”) and so was ALGORITHM=INSTANT (“Need to rebuild the table to change column type”), and a copy holds back writes for as long as it runs, as the post on which ALTER TABLE changes lock the table measured.

Before converting to TIMESTAMP, count the rows that will fail, with the session at +00:00 as the conversion should be:

SELECT COUNT(*) FROM subscriptions
WHERE expires_at < '1970-01-01 00:00:01' OR expires_at >= '2038-01-19 03:14:08';

How does Schemity show what a DATETIME or TIMESTAMP change costs?

Schemity’s impact analysis reports a conversion to TIMESTAMP as a change that fails if a value does not fit, counts the rows that will not, and plans the conversion in a UTC session.

Schemity is database design software that reads your live database, shows the impact of every schema change before it runs, and keeps the diagram as a file in Git. Connected to the test database, changing subscriptions.expires_at from DATETIME to TIMESTAMP on the diagram produced the planned SQL and two findings in the change preview, before anything ran:

SET time_zone = '+00:00';
ALTER TABLE `subscriptions` MODIFY COLUMN `expires_at` TIMESTAMP NOT NULL;

Impact analysis read “Changes the type of subscriptions.expires_at, fails if a value does not fit: ~3 rows” and “Rewrites subscriptions to change expires_at: ~3 rows, 16 KB on disk”, the 3 being the table’s estimated row count. Its exact count used to count every non-NULL value, here all 3. In the next release it counts only the values outside TIMESTAMP’s range, and on that table it found the 2 subscriptions expiring in 2041 and 2126, the two rows that made the ALTER fail when it ran. That is what it means to see the impact of every change: the failing rows are named before the copy starts. The SET time_zone line is there because a change between the two types converts values through the session’s zone; Schemity puts the connection’s own zone back afterwards. The field editor offers CURRENT_TIMESTAMP as a default on both types.

Schemity's change preview on MySQL 9.7.4 after changing subscriptions.expires_at from DATETIME to TIMESTAMP: the planned migration SET time_zone = '+00:00'; then ALTER TABLE subscriptions MODIFY COLUMN expires_at TIMESTAMP NOT NULL, one planned change marked altered, and two impact findings, Changes the type of subscriptions.expires_at, fails if a value does not fit: ~3 rows, and Rewrites subscriptions to change expires_at: ~3 rows, 16 KB on disk.

Schemity's Impact drawer on MySQL 9.7.4 for the same change: under Can fail on existing data, Changes the type of subscriptions.expires_at, fails if a value does not fit: ~3 rows, with Exactly 2 rows beside Show on canvas after Count exactly was pressed; under Rewrites the table, Rewrites subscriptions to change expires_at: ~3 rows, 16 KB on disk.

Three limits. Schemity does not warn that a TIMESTAMP column will need to hold a date after 2038; it only counts the rows that already do when you convert. The count compares stored values against the range, so a DATE or DATETIME written in local time is counted as if it were UTC. And impact analysis reads the database, not your application: a migration written by Laravel or Django and run outside Schemity sets whatever session time zone its own connection has, which Schemity cannot see.

Which type to choose, and how to switch

Choose DATETIME and write UTC; if a table already uses TIMESTAMP, convert it in a UTC session after counting what would not fit.

For an existing Laravel schema, timestamps() columns can stay as they are until something needs a date past 2038, but columns that hold future dates belong in DATETIME now ($table->dateTime('expires_at')). When converting a busy table in production, the usual route avoids the long copy altogether. Add a new created_at_utc DATETIME NULL column, write both from the application, backfill in batches with SET time_zone = '+00:00' on the backfill connection, switch reads, and a release later drop the old column and rename the new one to created_at. On 9.7.4 the add, the drop and the rename each ran with ALGORITHM=INSTANT, so only the batched backfill touches rows; without the SET time_zone, a backfill run at +07:00 wrote 09:00 for a 02:00 UTC value. gh-ost and pt-online-schema-change are the other usual route, and their connections need the same session zone check. On PostgreSQL the same choice has the names the other way round; see timestamp vs timestamptz, and the MySQL to PostgreSQL conversion for which MySQL type becomes which.

Frequently asked questions

Should I use DATETIME or TIMESTAMP in MySQL?

Use DATETIME and store UTC from the application, which is what Django (with USE_TZ = True) and Rails do. TIMESTAMP is only worth it when you want MySQL to convert every value through each connection's time zone, and your dates will always fall between 1970 and January 19, 2038.

What happens to a MySQL TIMESTAMP after 2038?

It cannot store it. TIMESTAMP ends at '2038-01-19 03:14:07' UTC, and on MySQL 9.7.4 inserting '2038-01-19 03:14:08' failed with error 1292, Incorrect datetime value, in the default strict mode. A subscription expiring in 2041 cannot go into a TIMESTAMP column today.

Does changing a column from TIMESTAMP to DATETIME change the values?

It can. MODIFY COLUMN ... DATETIME writes each value as the wall-clock time of the session running the change. In a test, a value stored as 02:00 UTC became 02:00 when converted in a UTC session and 09:00 when converted in a +07:00 session. Run SET time_zone = '+00:00' first so the stored values keep meaning UTC.