Should I be using a big integer or a regular integer in MySQL to store a timerstamp in? I plan on storing it in an INT and not the built in timestamp or datetime so which INT type should I use?
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 .) By default, the current time zone for each connection is the server's time.
Remarks. The int data type is the primary integer data type in SQL Server. The bigint data type is intended for use when integer values might exceed the range that is supported by the int data type. bigint fits between smallmoney and int in the data type precedence chart.
More precisely, the timestamp is an integer numeric value that expresses the number of seconds elapsed from an arbitrary date, ie midnight (UTC) of January 1, 1970, which is called epoch not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).
Timestamps in MySQL are generally used to track changes to records, and are often updated every time the record is changed. If you want to store a specific value you should use a datetime field.
Int would roll over to a negative in 2038 (if you are using UNIX timestamp): http://en.wikipedia.org/wiki/2038_problem.
so BIGINT is probably the safest choice
You should be storing it in a timestamp since that's most likely what the DBMS will optimize for timestamp data.
I'm curious as to why you would sacrifice all the hard work that the MySQL developers have put into making timestamps work the way they should, and replacing it with something that will almost certainly not work as well.
Since you don't state why you want to use an integer, I'm just going to assume it was temporary insanity and that you'll soon recover :-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With