View Full Version : timestamp/date help

08-21-2007, 11:10 PM

I want to display a feature which tells the user when the last time the page was updated in terms of minutes.

Each time the page is updated, i store the time it was updated in a database table. Then, when i visit the page, the value from the database is taken away from the current time.

I was wondering how i'd do this? And make it so it only displays minutes, so like, "This page was updated 7 minutes ago."

08-21-2007, 11:17 PM
// $then = old timestamp
$mins = ceil((time() - $then) / 60);
echo "This page was updated $mins minute" . ($mins > 1 ? 's' : '') . " ago.";
You could use round() or floor() instead of ceil() depending on how you want the result calculated.

08-21-2007, 11:26 PM
Awesome, thanks, just what i was lookin for :P