Search the Community
Showing results for tags 'counting'.
Found 1 result
Hello there, i was working on a website wich displayed the game time. So i read that i should not make to many calls to the API. To prevent the abuse of the API i made my own system written in PHP wich works very well. I want to share my code for other web devs. (I couldnt found one on the forum) <?php header('content-type: application/json; charset=utf-8'); //Original 2015-19-10 19:28:23 +0000 The date on the Docs seems to be wrong :/ reverse coding of current api stamp in minutes give me this date $format = 'Y-d-m H:i:s e'; $date = DateTime::createFromFormat($format, "2015-19-10 19:28:23 +0000"); $unixStart = $date->format('U'); //Convert time to Minutes $gameTime = ((time() - $unixStart) / 60) * 6; //Convert time to Seconds $gameTimeSeconds = (((time() - $unixStart) * 6) - 3660); //Optionally use of Day Strings like the Navi ingame $day = date("w", $gameTimeSeconds); $days = array("Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed"); $timeString = $days[$day].". ".date("H:i", $gameTimeSeconds); $arr = array("timeString" => $timeString); echo json_encode($arr, JSON_UNESCAPED_UNICODE); ?> If someone found some errors or problems. Feel free to answer