Jump to content

Time calculating at server query


Genert

Recommended Posts

Hello.

Check this: http://genert.impact.pri.ee/sfsf/?ip=74.63.64.44:27960

Now take a look at

Nextmap in 1 minute(s)

Map length: 30 minutes

The "Nextmap in 1minute(s)" is in HTML code,not in PHP and Map lenght: 30 minutes is in PHP

<span style="color:#080;">Map length: <?echo getValue("timelimit");?> minutes</span>

 

 

Now what I'm trying to get is: http://et.trackbase.net/index.php?mod=serverinfo&idx=11179

There is:

Nextmap in 11 minute(s)

Map length: 30 min (61%)

Now how I can get the same thing,using getValue("timelimit") function?

It should/must use timelimit and countdown the map time in minutes and add (%) of how many time has gone.

My brain stucked at this point.

Link to comment
https://forums.phpfreaks.com/topic/240254-time-calculating-at-server-query/
Share on other sites

I tried this:

<span style="color:#0d0">Nextmap in <? echo time_left(getValue("timelimit"));?></span>

 

In functions.php:

function time_left($integer) { 

     $seconds=$integer; 

     if ($seconds/60 >=1) 

     { 

     $minutes=floor($seconds/60); 

     if ($minutes/60 >= 1) 

     { # Hours 

     $hours=floor($minutes/60); 

     if ($hours/24 >= 1) 

     { #days 

     $days=floor($hours/24); 

     if ($days/7 >=1) 

     { #weeks 

     $weeks=floor($days/7); 

     if ($weeks>=2) $return="$weeks Weeks"; 

     else $return="$weeks Week"; 

     } #end of weeks 

     $days=$days-(floor($days/7))*7; 

     if ($weeks>=1 && $days >=1) $return="$return, "; 

     if ($days >=2) $return="$return $days days";

     if ($days ==1) $return="$return $days day";

     } #end of days

     $hours=$hours-(floor($hours/24))*24; 

     if ($days>=1 && $hours >=1) $return="$return, "; 

     if ($hours >=2) $return="$return $hours hours";

     if ($hours ==1) $return="$return $hours hour";

     } #end of Hours

     $minutes=$minutes-(floor($minutes/60))*60; 

     if ($hours>=1 && $minutes >=1) $return="$return, "; 

     if ($minutes >=2) $return="$return $minutes minutes";

     if ($minutes ==1) $return="$return $minutes minute";

     } #end of minutes 

     $seconds=$integer-(floor($integer/60))*60; 

     if ($minutes>=1 && $seconds >=1) $return="$return, "; 

     if ($seconds >=2) $return="$return $seconds seconds";

     if ($seconds ==1) $return="$return $seconds second";

     $return="$return."; 

     return $return; 

}

 

And result: http://genert.impact.pri.ee/sfsf/?ip=188.165.209.117:29000 it shows same time,but in seconds,stilt...how I can do it?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.