title: MySQL: Convert relative seconds count to datetime?
body: <p>I have a MySQL database show uptime for devices.  The uptime is how long the device has been up in seconds.  I have a query showing all devices with uptime less than 86400 (24 hours) which I want to bring into a PHP page.  </p>
  
  <p>I want to format this uptime string number into a datetime that's human readable.  Here is my query:</p>
  
  <pre><code>select hostname,type,uptime from devices where uptime &lt; 86400
  
  And here is sample output:
  hostname: serverA
  type: server
  uptime: 10329
  </code></pre>
  
  <p>How can I turn that 10329 into an actual time?  I assume there is some sort of value that can pull the current time in seconds, minus that uptime value, and convert that into MM/DD/YYYY HH:MM:SS readable value?</p>
  
  <p>Any help is great appreciated!</p>
  
  <p>EDIT:
  Decided to use both answer below, but here is the query that fits my needs:</p>
  
  <pre><code>SELECT hostname AS Server,type AS Type,NOW() - INTERVAL uptime SECOND AS "Boot Time",last_polled AS "Last SNMP Poll" FROM devices WHERE uptime &lt; 86400
  </code></pre>
  
  <p>Which returns:</p>
  
  <pre><code>Server: ServerA
  Type: server
  Boot Time: 2014-02-11 13:26:52
  Last SNMP Poll: 2014-02-11 18:35:14
  </code></pre>