Genert Posted June 23, 2011 Share Posted June 23, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/240254-time-calculating-at-server-query/ Share on other sites More sharing options...
Genert Posted June 23, 2011 Author Share Posted June 23, 2011 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? Quote Link to comment https://forums.phpfreaks.com/topic/240254-time-calculating-at-server-query/#findComment-1234093 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.