note 9676 added to time
| From: | webmaster at dark-library dot com | Date: | Sat, 18 Nov 2000 09:10:42 +0000 |
| Subject: | note 9676 added to time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7858@lists.php.net to get a copy of this message | ||
ok for this thing that shows how long somone was online i wrote this... what you do is use the time
stamp of the when someone did something and then subtract it from the current time() and then put it
into this
$online_for = (time()-<time logged on>);
if($online_for < 60){ $sec=$online_for; $min=0; $hour=0; }
else
if($online_for < 3600){ $sec=$online_for%60; $hour=0; $min_t = explode('.',
number_format($online_for/60,2)); $min=$min_t[0]; }
else
if($online_for >= 216000){ $hour_t = explode('.',
number_format($online_for/216000,2)); $hour=$hour_t[0]; $sec=$online_for%60; $min_te =
$online_for%216000; $min_t = explode('.', number_format($min_te/60,2)); $min=$min_t[0];}
and this out puts $hour, $min and $sec
the code looks wacko but it was the best way to do what i wanted ;)
http://www.php.net/manual/function.time.php