It is necessary to get all the records for the last 30 days (at the time the time is given as date bigint (20) and is written there via time ()) Request:

SELECT `id` FROM `product` WHERE `date` BETWEEN '".time()-30."' AND '".time()."' 

Nothing gives even in the interval there are fields for sampling

  • one
    fromunixtime function - splash58
  • changed SELECT id `FROM product WHERE date BETWEEN FROM_UNIXTIME (". time () - 30. ") AND FROM_UNIXTIME (". time (). ")` same thing - ddeadlink

1 answer 1

If I understand correctly, you deduct 30 seconds , not days. time () returns seconds.

You can do this:

 SELECT `id` FROM `product` WHERE `date` > '".(time() - 30 * 24 * 3600)."' 

Or do without time () and use UNIX_TIMESTAMP ():

 SELECT `id` FROM `product` WHERE `date` > UNIX_TIMESTAMP() - 30 * 24 * 3600 
  • one
    It’s much nicer to work at intervals: select id from product where date > now()-interval 30 day - Mike