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.
I'm Baron Schwartz, the founder and CEO of VividCortex. I am the author of High Performance MySQL and lots of open-source software for performance analysis, monitoring, and system administration. I contribute to various database communities such as Oracle, PostgreSQL, Redis and MongoDB. More about me.