title: How to check if a timestamp is set in MySQL and PHP?
body: <p>When a timestamp column is defined as <code>DEFAULT 0</code>, if it's not specified in INSERT or UPDATE, '0000-00-00 00:00:00' becomes the default value.</p>
  
  <p>What's the proper way to check if such a timestamp is set thus not the default value?</p>
  
  <pre><code>SELECT * FROM table WHERE timestamp &lt;&gt; 0
  </code></pre>
  
  <p>It does seem to work but I'm not sure if it's the proper way and work 100% cases?</p>
  
  <p>And when such value gets selected in PHP, how to check if it's set or not?</p>
  
  <p>Thus far, I came up with something like this:</p>
  
  <pre><code>if ($row['timestamp'] != '0000-00-00 00:00:00') {
  }
  </code></pre>
  
  <p>It does work but it seems tacky to me. I'm not so sure if its the proper way neither. What should I do instead?</p>