shadiadiph Posted June 1, 2009 Share Posted June 1, 2009 I am having a problem I have a field set from strttime $timenow = date("h:i:s"); $refreshtime = strtotime($timenow); problem is i have seen that if someone else logs in from a diferent time zone the strtotime set by there computer seems to be about 7000 seconds behind mine how can I force this to work properly? As my sql query deletes a user when the users computer has not refreshed for more than 30 seconds problem is it isn't setting every 5 or 6 seconds like on mine it sets the strtotime from the alternate time zone as -7000 ish Quote Link to comment https://forums.phpfreaks.com/topic/160537-time-problem/ Share on other sites More sharing options...
Daniel0 Posted June 1, 2009 Share Posted June 1, 2009 As my sql query deletes a user when the users computer has not refreshed for more than 30 seconds No offense, but that sounds pretty stupid. What if your user goes out to take a shit or something? Anyway, just have to enter the time offset and subtract/add it to the timestamp. Same concept as you'll see here for setting the time zone on this forum. Quote Link to comment https://forums.phpfreaks.com/topic/160537-time-problem/#findComment-847236 Share on other sites More sharing options...
shadiadiph Posted June 1, 2009 Author Share Posted June 1, 2009 hi daniel i am just going to look at that by the way if the user goes to the toilet it will not log them out i have a script running in the background that refreshes the script not the entire page so it will only log them out if they leave the site Quote Link to comment https://forums.phpfreaks.com/topic/160537-time-problem/#findComment-847259 Share on other sites More sharing options...
shadiadiph Posted June 1, 2009 Author Share Posted June 1, 2009 mm one problem i forsee here is i have no idea where my server is not sure if it is USA or canada I am in Asia Quote Link to comment https://forums.phpfreaks.com/topic/160537-time-problem/#findComment-847270 Share on other sites More sharing options...
shadiadiph Posted June 1, 2009 Author Share Posted June 1, 2009 in theory if i use this in the top of the documents that check the user will it force their computer to use this timezone? ini_set('date.timezone', 'US/Eastern'); Quote Link to comment https://forums.phpfreaks.com/topic/160537-time-problem/#findComment-847293 Share on other sites More sharing options...
shadiadiph Posted June 1, 2009 Author Share Posted June 1, 2009 sorry i have never done anything with timezones before but this is what i have figured out so far if i print date("D M j G:i:s T Y")."<br />"; i get Mon Jun 1 18:30:10 EDT 2009 if i use print date("Z")."<br />"; this gives me the offset correct which is -14400 seconds which is 4 hours behind GMT or UTC?? The thing i don't get is my server is in the USA I am in Thailand when i run my script if i use $timenow = date("h:i:s"); $refreshtime = strtotime($timenow); but this is producing a date in the USA so why when a user from somewhere else is it storing differently in the database?? I had one user my refresh times were showing a time difference of 11 seconds and the othe users was -7000 and something for example this is what i am using $timenow = date("h:i:s"); $refreshtime = strtotime($timenow); $checkguests ="select * from online where log='Yes' AND lev='0' AND oID='$oid'"; $resultcheckguests = mysql_query($checkguests); while($row = mysql_fetch_array($resultcheckguests)) { $grefresh = $row["refresh"]; $timelimit = $refreshtime - $grefresh; } $updateguests = "update online set refreshdiff='$timelimit' where oID='$oid'"; $resultupdateguests = mysql_query($updateguests); $recheckguests ="select * from online where lev='0' and log='Yes'"; $resultrecheckguests = mysql_query($recheckguests); while($row = mysql_fetch_array($resultrecheckguests)) { $guestdifference = $row["refreshdiff"]; $deleteguests ="delete from online where lev='0' and refreshdiff >30 OR lev='0' AND log='No' "; $resultdeleteguests = mysql_query($deleteguests); } this is working for me my server is in the USA I am in Asia when i run it my refreshdiff time is always betwen 5-10 seconds but when a user was online earlier it says his refreshdiff was -7000 why would this work differently for a user from somewhere else when i print date it isnt showing me as being in Thailand it shows USA EDT time? surely the other user it should be showing EDT time also?? Quote Link to comment https://forums.phpfreaks.com/topic/160537-time-problem/#findComment-847350 Share on other sites More sharing options...
shadiadiph Posted June 1, 2009 Author Share Posted June 1, 2009 is it possible the user i saw online was actually a spambot of somekind with a weird setting? Quote Link to comment https://forums.phpfreaks.com/topic/160537-time-problem/#findComment-847354 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.