Difference between DATETIME and TIMESTAMP in MySQL
TIMESTAMPtype in MySQL is often used to track changes to records such as keeping track of the last modified time of a record.
This is possible by setting a column to auto-update.
The reason the
TIMESTAMPtype is suited for this is because everything is stored in UTC (Coordinated Universal Time), which allows for tracing back to a single point in time.
DATETIMEtype does not necessarily allow us to trace back to a single point in time as we do not necessarily know the timezone for the
However, the advantage of the
DATETIMEtype is that the supported range of values
'9999-12-31 23:59:59'is much larger than that of
'1970-01-01 00:00:01'UTC to
This makes it more suited for storing date and time information that is likely to fall outside the range of
TIMESTAMP(e.g. storage of Date of Birth information).