shlomikalfa Posted May 9, 2008 Share Posted May 9, 2008 hey there i want to know what's the easiest way to do the following. > Collect last update form server [MySql] in format: 2008-05-09 15:52:23 > Collect current time from php in format: date('Y-m-d H:i:s'), Should return same format. > Check out if it's been 5 minutes since the last update. Purpose: i have a server that holds all sort of variables in different tables, it also has a specific ''ServerDetails'' table to hold all the necessary details together, now i don't want to overload the server with updating the details at every page watch so i want have a 'LastUpdate' variable which will be checked to see if it has been $X time from the last update then collect the details again... IE: Table1:: username | pass | something... Table2:: Actions | ToDo | something.... ServerDetails:: Total users | Total Actions | Total something | last update [move]Thanks for reading and supporting !!!!![/move] Link to comment https://forums.phpfreaks.com/topic/104859-solved-find-out-if-time-passed-since-date/ Share on other sites More sharing options...
ILYAS415 Posted May 9, 2008 Share Posted May 9, 2008 Hi. Theres a simple way to do it. Use cron jobs. http://www.siteground.com/tutorials/cpanel/cron_jobs.htm Link to comment https://forums.phpfreaks.com/topic/104859-solved-find-out-if-time-passed-since-date/#findComment-536715 Share on other sites More sharing options...
shlomikalfa Posted May 9, 2008 Author Share Posted May 9, 2008 well.. i don't see any cron jobs in my control panel [1and1]... anyway to do what's PHPBB do for updating the ammount of users and so ? Link to comment https://forums.phpfreaks.com/topic/104859-solved-find-out-if-time-passed-since-date/#findComment-536962 Share on other sites More sharing options...
moselkady Posted May 9, 2008 Share Posted May 9, 2008 You can try something like this: <?php $row = mysql_query("SELECT last_update FROM ServerDetails"); $row = mysql_fetch_array($row); if (time()-strtotime($row['last_update']) >= 300) { // do updates } ?> Link to comment https://forums.phpfreaks.com/topic/104859-solved-find-out-if-time-passed-since-date/#findComment-537005 Share on other sites More sharing options...
NorthWestSimulations Posted May 9, 2008 Share Posted May 9, 2008 as moselkady said StrToTime(); is the best function to use when dealing with time. Link to comment https://forums.phpfreaks.com/topic/104859-solved-find-out-if-time-passed-since-date/#findComment-537098 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.