In many of my MySQL database tables, I have been storing timestamps (from the php time()
) in int UNSIGNED
fields. However, time()
returns 13 digit values if I recall correctly, and INT UNSIGNED
stores values up to 2147483647
which is only 10 digits in length. Therefore any value returned by time()
will be too large a number to be stored in an int
field.
However, none of my timestamps have been truncated, so how is it able to store such large values? Is it a database inconsistency or am I missing something?
1343399732 seconds has currently elapsed since the epoch (1970) , which can well be stored in a signed int.
It's dealing with seconds related to around the year 2038 that will start cause you trouble when you store the seconds in a signed 32 bit int.