A simple rule for sane timestamps in MySQLThu, Jan 30, 2014 in Databases
Do you store date or time values in MySQL?
Would you like to know how to avoid many possible types of pain, most of which you cannot even begin to imagine until you experience them in really fun ways?
Then this blog post is for you. Here is a complete set of rules for how you can avoid aforementioned pain:
- All date and time columns shall be
INT UNSIGNED NOT NULL, and shall store a Unix timestamp in UTC.
Enjoy all the spare time you’ll have to do actually useful things as a result.
About The Author
Baron is the founder and CEO of VividCortex. He is the author of High Performance MySQL and many open-source tools for performance analysis, monitoring, and system administration. Baron contributes to various database communities such as Oracle, PostgreSQL, Redis and MongoDB.