Search code examples
phpmysqlepoch

MySQL, result bigger than X number


I’m trying to get the results of the past 15 days in a database. The time is added in epoch format, like 1400904415.

I’m trying to get only the last results (15 days), so I’m wondering if it is possible to do something like this:

SELECT * FROM dataadded WHERE createdate="here something like createdate its bigger than currentdate - 15 days"

Is that possible?


Solution

  • You can also do this in PHP if you don't want to offload the work to your database

     $date = time() - (86400 * 15); //86400 seconds = 1 day
     $sql = 'SELECT * FROM dataadded WHERE createdate=' . $date;