iLazlow Posted April 24, 2018 Share Posted April 24, 2018 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 Link to comment Share on other sites More sharing options...
Guest Posted April 24, 2018 Share Posted April 24, 2018 thanks I will apply it in mine Link to comment Share on other sites More sharing options...
chipmunk197 Posted April 24, 2018 Share Posted April 24, 2018 how do i apply this Link to comment Share on other sites More sharing options...
iLazlow Posted April 24, 2018 Author Share Posted April 24, 2018 2 minutes ago, chipmunk197 said: how do i apply this What did you mean? You create an .php file (just create an txt file and rename it to yourfile.php) open the file with notepad++ or somethin copy my code & paste it in your file. upload the file to your webspace (your webspace requires php) done. Link to comment Share on other sites More sharing options...
Jack Douglas Posted April 24, 2018 Share Posted April 24, 2018 You could have tried this. http://carbon.nesbot.com/ Should automatically do it for you Link to comment Share on other sites More sharing options...
Nathan Posted April 24, 2018 Share Posted April 24, 2018 14 minutes ago, JackDouglas said: You could have tried this. http://carbon.nesbot.com/ Should automatically do it for you That is not needed. What OP has at the moment is sufficient considering it is manually changed anyway. Carbon would not do it automatically. Link to comment Share on other sites More sharing options...
Guest Posted October 22, 2018 Share Posted October 22, 2018 the reason for the difference in time you've seen is that there's some drift in time's progression, due to outages, slow processing of the jobs, and other various reasons. Its existence was made specifically to make sure that game time in-game only ever progressed forward, back in the day, it would reset to 0 every time the servers where restarted. You can safely query the API endpoint, but make sure that you cache the response , you will likely see drift in the future as well Link to comment Share on other sites More sharing options...
Recommended Posts