Possible Duplicates:
Output is in seconds. convert to hh:mm:ss format in php
How can i display seconds ago/minutes ago/with unix timestamp?
I have this users online script I am working on. So far it is as follows...
while ($online_user = $q -> fetch(PDO::FETCH_ASSOC)) {
$last_active = time() - $online_user['online'];
echo '<p>' . $online_user['username'] . ' was last active ' . $last_active . ' seconds
ago.</p>';
}
$online_user['online'] is the last time() the user was active on the website. So when I minus it from the current time() it gives me the amount of seconds ago that they were last active.
Thing is at the minute it echos like this:
Some username was last active 567 seconds ago.
I would like to know how I can make it echo so it would instead convert it to minutes and seconds so it would look something like this;
Some username was last active 9 minutes and 27 seconds ago.
Thanks in advance if you know of anywhere I could learn this please post a link. :)