Time Online

Started on the old forum in October 2008 · view the original in the archive · old links redirect here

20 replies · 1,829 views · started 18 years ago · 1 min read

9 participants
Guest #1

Hi everyone ive searched the forums for this with no luck im trying to find the coding for time online (example) Time online: 1 hour 46 mins 3 secs any help wud be grateful

friend Developer · 112 posts #2

Also if any code for time idle ....thanks

GumSlone Administrator Principal · 1,690 posts #3

save the time when a user has logged in and substract it from current time the diference would be the online time.

round((time()-$login_time)/60); //minutes online

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

ori Lead · 512 posts #4

i made this code can use it for idle and online time it will give the msg from seconds so like doing time()-lastseen then that value goes in this function also it does up to weeks if u want put months and years in jus add them lol its easy

function TimeMsg($secs)
{
$mins=floor(($secs)/60);
$hours=floor(($mins)/60);
$days=floor(($hours)/24);
$weeks=floor(($days)/7);
if($secs>59)$secs=$secs-($mins*60);
if($mins>59)$mins=$mins-($hours*60);
if($hours>23)$hours=$hours-($days*24);
if($days>6)$days=$days-($weeks*7);
$msg="";
if($weeks>0)$msg.=$weeks." week";
if($weeks>1)$msg.="s";
if($weeks>0&&$days>0)$msg.=", ";
if($days>0)$msg.=$days." day";
if($days>1)$msg.="s";
if(($days>0||$weeks>0)&&$hours>0)$msg.=", ";
if($hours>0)$msg.=$hours." hour";
if($hours>1)$msg.="s";
if(($hours>0||$days>0)&&$mins>0)$msg.=", ";
if($mins>0)$msg.=$mins." minute";
if($mins>1)$msg.="s";
if($mins>0&&$secs>0)$msg.=", ";
if($secs>0)$msg.=$secs." second";
if($secs>1)$msg.="s";
if(!$secs&&!$mins&&!$hours&&!$days)$msg="0 seconds";
return $msg;
}
friend Developer · 112 posts #5

QUOTE (ori @ Oct 3 2008, 12:17 AM) <{POST_SNAPBACK}>

i made this code can use it for idle and online time it will give the msg from seconds so like doing time()-lastseen then that value goes in this function also it does up to weeks if u want put months and years in jus add them lol its easy

function TimeMsg($secs)
{
$mins=floor(($secs)/60);
$hours=floor(($mins)/60);
$days=floor(($hours)/24);
$weeks=floor(($days)/7);
if($secs>59)$secs=$secs-($mins*60);
if($mins>59)$mins=$mins-($hours*60);
if($hours>23)$hours=$hours-($days*24);
if($days>6)$days=$days-($weeks*7);
$msg="";
if($weeks>0)$msg.=$weeks." week";
if($weeks>1)$msg.="s";
if($weeks>0&&$days>0)$msg.=", ";
if($days>0)$msg.=$days." day";
if($days>1)$msg.="s";
if(($days>0||$weeks>0)&&$hours>0)$msg.=", ";
if($hours>0)$msg.=$hours." hour";
if($hours>1)$msg.="s";
if(($hours>0||$days>0)&&$mins>0)$msg.=", ";
if($mins>0)$msg.=$mins." minute";
if($mins>1)$msg.="s";
if($mins>0&&$secs>0)$msg.=", ";
if($secs>0)$msg.=$secs." second";
if($secs>1)$msg.="s";
if(!$secs&&!$mins&&!$hours&&!$days)$msg="0 seconds";
return $msg;
}

Thanks ori but whats usage code?

Thanks

Guest #6

QUOTE (friend @ Oct 23 2008, 05:26 AM) <{POST_SNAPBACK}>

Thanks ori but whats usage code?

Thanks

just use methos script author hehehe..

friend Developer · 112 posts #7

QUOTE (DarkSilent @ Oct 23 2008, 05:48 AM) <{POST_SNAPBACK}>

just use methos script author hehehe..

Thanks 🙂

friend Developer · 112 posts #8

I got

Member For: 42 years 2 months 6 hours 51 seconds

ori Lead · 512 posts #9

for online time jus use the seconds they been online 4 and for idle time use the difference between time now and last seen time so 61 would return 1 minute , 1 second

friend Developer · 112 posts #10

ok i get online time for recent

but

I also get in forum post on 2nd and other page date 31-12-69

dont know why

jsyguy23 Developer · 134 posts #11

you must of replacet the old time format pmsl

Guest #12

in index.php?action=viewuser

$totaltimeonline = mysql_fetch_array(mysql_query("SELECT tottimeonl FROM ibwf_users WHERE id='".$who."'"));  
$num = $totaltimeonline[0]/86400;
$days = intval($num);
$num2 = ($num - $days)*24;
$hours = intval($num2);
$num3 = ($num2 - $hours)*60;
$mins = intval($num3);
$num4 = ($num3 - $mins)*60;
$secs = intval($num4);
echo "Time Online: ";
if(($days==0) and ($hours==0) and ($mins==0)){
 echo "[b]$secs[/b] seconds
";
}else
if(($days==0) and ($hours==0)){
 echo "[b]$mins[/b] mins, ";
echo "[b]$secs[/b] seconds
";
}else
if(($days==0)){
echo "[b]$hours[/b] hours, ";
echo "[b]$mins[/b] mins, ";
echo "[b]$secs[/b] seconds
";
}else{
echo "[b]$days[/b] days, ";
 echo "[b]$hours[/b] hours, ";
echo "[b]$mins[/b] mins, ";
echo "[b]$secs[/b] seconds
";
}
$noi = mysql_fetch_array(mysql_query("SELECT lastact FROM ibwf_users WHERE id='".$who."'"));
echo "$idleofline ";
 $idleofline = "Idle For:";
$remain = time() - $noi[0];
$num = $remain/86400;
$days = intval($num);
$num2 = ($num - $days)*24;
$hours = intval($num2);
$num3 = ($num2 - $hours)*60;
$mins = intval($num3);
$num4 = ($num3 - $mins)*60;
$secs = intval($num4);
if(($days==0) and ($hours==0) and ($mins==0)){
echo "[b]$secs[/b] seconds
";
}else
if(($days==0) and ($hours==0)){
echo "[b]$mins[/b] mins, ";
 echo "[b]$secs[/b] seconds
";
}else
if(($days==0)){
 echo "[b]$hours[/b] hours, ";
echo "[b]$mins[/b] mins, ";
echo "[b]$secs[/b] seconds
";
}else{
echo "[b]$days[/b] days, ";
 echo "[b]$hours[/b] hours, ";
 echo "[b]$mins[/b] mins, ";
 echo "[b]$secs[/b] seconds
";
}

add new row in ibwf_users

 `tottimeonl` int(100) NOT NULL default '0',
bijaybd Developer · 178 posts #13

can somebody make it for mobile chat 2.0.2 by ghost and device

friend Developer · 112 posts #14

QUOTE (jsyguy23 @ Oct 24 2008, 04:14 AM) <{POST_SNAPBACK}>

you must of replacet the old time format pmsl

where to replace that?

strikingv Developer · 70 posts #17

It wont work 0n u. 😀 . Its lavalair chat scripts

jsyguy23 Developer · 134 posts #18

add this in core to ya addonline function $lastact=mysql_fetch_array(mysql_query("SELECT lastact FROM members WHERE uid='".$uid."'")); $user_time=mysql_fetch_array(mysql_query("SELECT timeon FROM members WHERE uid='".$uid."'")); $timetoadd=microtime(get_as_float)-$lastact[0]; if($timetoadd>120)$timetoadd=0; mysql_query("UPDATE members SET timeon='".($user_time[0]+$timetoadd)."' WHERE uid='".$uid."'");

and this in profiles echo "Time Online: ".gettimemsg($pinfo[4])." ";

and sql timeon int(255) NOT NULL default '0',

muzza345 Junior · 41 posts #19

This one aint working for me proper. The code above just shows in my profile time online : online. Even when a member isnt on

jsyguy23 Developer · 134 posts #20

give it time it will change m8 trust me

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close