Jump to content

time problem


shadiadiph

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/160537-time-problem/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/160537-time-problem/#findComment-847236
Share on other sites

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??

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/160537-time-problem/#findComment-847350
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.