If I have a table that has a TIMESTAMP column, and I want to retrieve only the rows that were added after a php variable that was set by $time=strtotime(“now”) was created, how would I format the query syntax?
$q= “SELECT * FROM webchat_lines WHERE author = ‘someone’ *{between $time and CURRENT_TIMESTAMP}* ORDER BY id DESC LIMIT 20″;
Try:
This uses
FROM_UNIXTIME($time)to convert thestrtotimeoutput (seconds since 1970-xx-xx etc) to a date so it can be compared to your timestamp column.NOW()is an alias forCURRENT_TIMESTAMP().