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] Quote 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 Quote 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 ? Quote 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 } ?> Quote 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. Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.