title: Getting last 24 hours data from MySQL in PHP with custom date string
body: <p>I'm adding a custom date string to the database by using;</p>
  
  <pre><code>$date = date("H:i:sa | d-m-Y");
  $sql = "INSERT INTO data
          (artist, title, presenter, timeplayed)
          VALUES('$artist','$title','$presenter','$date')";
  </code></pre>
  
  <p>However I can't then quite figure out how to get $date back out but only the last 24 hours worth of entries. So between 00:00:00 yesterday and 23:59:59 today.</p>
  
  <p>I've tried:</p>
  
  <pre><code>SELECT * FROM data WHERE timeplayed &gt; DATE_SUB( NOW(), INTERVAL 24 HOUR)
  </code></pre>
  
  <p>And similar,  however it's bringing back data older than 24 hours.</p>
  
  <p>I'm storing the data in timeplayed as varchar. I wonder if that's the reason?</p>