Jump to content

[ resolved ] simple question..


acidglitter

Recommended Posts

So I have this code that I got off from a website...

[code]$tomorrow = mktime(0,0,0,date("m"),date("d")-3,date("Y"));
echo "3 days ago.. ".date("F d, Y", $tomorrow);[/code]

I just changed it so it shows a date from 3 days ago.. So.. I'm wondering, how could I show all the rows in a table with a date from 3 or more days ago?
Link to comment
https://forums.phpfreaks.com/topic/27752-resolved-simple-question/
Share on other sites

Something like this maybe?  It assumes the field 'date' is a DATETIME.  If it's a unix timestamp, then remove the FROM_UNIXTIME function.  Just run the query as you would any other.  It's not tested but it should work.

[code]
$three_days_ago = mktime(0,0,0,date("m"),date("d")-3,date("Y"));

$sql = "SELECT * FROM table WHERE date <= FROM_UNIXTIME($three_days_ago)";
[/code]

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.