title: Using MySQL's TIMESTAMP vs storing timestamps directly
body: <p>I'm in a dilemma about saving date and time values in MySQL's TIMESTAMP format vs in a custom UNSIGNED INT format. The main considerations here are speed of retrieval, appropriate range calculations in PHP and occasional formatting into human readable values.</p>
  
  <p>The storage space required for each type and their ranges:</p>
  
  <pre><code>DATETIME        8 bytes  '1000-01-01 00:00:00' to '9999-12-31 23:59:59'
  TIMESTAMP       4 bytes  '1970-01-01 00:00:01' UTC to '2038-01-19 03:14:07' UTC
  UNSIGNED INT    4 bytes  (Maximum Value 4294967295)
  </code></pre>
  
  <p>I dont need the range of DATETIME at all. I'm torn between TIMESTAMP and UNSIGNED INT.</p>
  
  <p>Arguments in favor of UNSIGNED INT:</p>
  
  <ul>
  <li>A UNIX timestamp of 4294967295 converts to Sun, 07 Feb 2106 06:28:15 GMT which is more than TIMESTAMP and good enough for me</li>
  <li>Comparing these timestamps directly in PHP would be faster rather than converting TIMESTAMPs via strtotime() and then comparing them</li>
  </ul>
  
  <p>The only advantage TIMESTAMP would give me is when I'm reading in the values from the mysql table manually and need to 'see' them.</p>
  
  <p>Is there any compelling reason to use TIMESTAMP and not an UNSIGNED INT?</p>