Time Online
Started on the old forum in October 2008 · view the original in the archive · old links redirect here
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
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;
}
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
QUOTE (friend @ Oct 23 2008, 05:26 AM) <{POST_SNAPBACK}>
Thanks ori but whats usage code?
Thanks
just use methos script author hehehe..
QUOTE (DarkSilent @ Oct 23 2008, 05:48 AM) <{POST_SNAPBACK}>
just use methos script author hehehe..
Thanks 🙂
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',
QUOTE (jsyguy23 @ Oct 24 2008, 04:14 AM) <{POST_SNAPBACK}>
you must of replacet the old time format pmsl
where to replace that?
QUOTE (bijaybd @ Oct 28 2008, 10:27 PM) <{POST_SNAPBACK}>
can somebody make it for mobile chat 2.0.2 by ghost and device
i don't think is it possible..that chat don't have database but file.txt
the italian/international COMMUNITY of friendship http://people2000.netne.net WAP/WEB peoplemailbox@katamail.com
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',