At some point in this documentation MySQL exposes something like this:
link (English link)
TIMESTAMP has a range of '1970-01-01 00:00:01' GMT to '01 / 09/2038
03:14:07 'GMT.
DATETIME is used when you need values that contain both the
date and time MySQL retrieves and displays the DATETIME values in
'YYYY-MM-DD HH: MM: SS' format. The admitted range is '01 / 01/1000
00:00:00 'a' 9999-12-31 23:59:59 '.
Starting from the above and keeping this in mind, it is possible that the range of data that you could store or be interested in will incline you in favor of one or the other, for example if you work with mortgages for saying something it is easy for you exceed the TIMESTAMP
range today.
TIMESTAMP
is affected by the settings / settings of the time zone. While DATETIME
is constant.
TIMESTAMP
is four bytes and DATETIME
of eight bytes, consequently timestamps ( TIMESTAMP
) are also lighter in the database, with faster indexing.
Taking into account all the above if you want to store a specific value "it might be better" to use DATATIME
, but if what you want is to store to make a follow-up of possible changes in the records, you may want to use TIMESTAMP
when a record changes.
If you are working on MySQL 5
or higher, the values of TIMESTAMP
are converted from the current time zone to UTC for almacenamiento
, and converted back from UTC to the current time zone for recuperación
. only for the TIMESTAMP data type.
(NOTE if I find the link of the above I will try to put it here)
I hope I help you.