View Full Version : timestamp/date help

08-22-2007, 12:10 AM

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-22-2007, 12:17 AM
// $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-22-2007, 12:26 AM
Awesome, thanks, just what i was lookin for :P