MySQL datetime vs timestamp

By | December 1, 2012

Both data types: timespamp and datetime can be used to store a date and a time in a MySQL table. So what are the difference between these two and which one should I use in which cases?

The usual use of timestamps in MySQL is in generall to track changes of record (fields like created, last_changed). If you want to store a specific value you should use a datetime field. In MYSQL 5 and above, TIMESTAMP values are converted from the current time zone to UTC for storage, and converted back from UTC to the current time zone for retrieval.  (This occurs only for the TIMESTAMP data type, and not for other types such as DATETIME.)

One thought on “MySQL datetime vs timestamp

Leave a Reply