Time :d

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

4 replies · 468 views · started 17 years ago · 1 min read

3 participants
ionutxp Developer · 137 posts #1

who cand edit this function

function gettimemsg($sec)
{
$days=0;
$mins=0;
$hours=0;

if ($sec>59)
{
$secs=$sec%60;
$mins=$sec/60;
$mins=(integer)$mins;
}

if ($mins>60)
{
$hours=$mins/60;
$hours=(integer)$hours;
$mins=$mins%60;
}

if ($hours>24)
{
$days=$hours/24;
$days=(integer)$days;
$hours=$hours%24;

}
if($days>0)
{
return "$days days, $hours hours, $mins mins, $secs secs";
}
if($days<1)
{

if($hours>0)
{
return "$hours hours, $mins mins, $secs secs";
}
if($hours<1)
{
return "$mins mins, $secs secs";
}
}
}

to work to show only second fi the time is unde 1 min ...and the week , and month ....tried 2 do that but fall 🙁

Hate romains that take codes from here and tell to all that they had made that External image (may be gone)

Anshul Senior · 296 posts #2

it wil be like this

function gettime($timeinseconds)
{
if($timeinseconds < 60 && $timeinseconds >= 0) $var = "sec.";
elseif($timeinseconds < 3600 && $timeinseconds > 60)
{
$new = $timeinseconds;
$timeinseconds = $new/60;
$var = "min.";
}
elseif($timeinseconds < 86400 && $timeinseconds > 3600)
{
$new = $timeinseconds;
$timeinseconds = $new/3600;
$var = "hours";
}
elseif($timeinseconds > 86400)
{
$new = $timeinseconds;
$timeinseconds = $new/86400;
$var = "days";
}
$timeinseconds = round($timeinseconds, 2);
if($timeinseconds) return 'Idle Time: '.$timeinseconds.' '.$var.'
\n';
}
ionutxp Developer · 137 posts #3

🙁 mmm not that i told ...pfff to show the only seconds if is under 1 minute :(// and weeks and months

Hate romains that take codes from here and tell to all that they had made that External image (may be gone)

friend Developer · 112 posts #4

//////////////////////////gettimemsg

function gettimemsg($secs) { $mins=floor(($secs)/60); $hours=floor(($mins)/60); $days=floor(($hours)/24); $weeks=floor(($days)/7); if($secs>59)$secs=$secs-($mins60); if($mins>59)$mins=$mins-($hours60); if($hours>23)$hours=$hours-($days24); if($days>6)$days=$days-($weeks7); $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; }

usage

$noi = mysql_fetch_array(mysql_query("SELECT lastact FROM ibwf_users WHERE id='".$who."'")); $var1 = date("His",$noi[0]); $var2 = time(); $var21 = date("His",$var2); $var3 = $var21 - $var1; $var4 = date("s",$var3); echo "Idle For: "; $remain = time() - $noi[0]; $idle = gettimemsg($remain); echo "$idle ";

$nopl = mysql_fetch_array(mysql_query("SELECT regdate FROM ibwf_users WHERE id='".$who."'")); $membrage = time() - $nopl[0]; $membrage = gettimemsg($membrage); echo "Member For: $membrage ";

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