gaza165 Posted April 15, 2009 Share Posted April 15, 2009 Hi all, can someone tell me whenever i update my users timestamp on the server it always starts at 3600 but locally it always starts at 0. this is the code im running... user_online.php <?php session_start(); include("dbconnect.php"); $sql = mysql_query("SELECT last_activity,username FROM users"); echo "<ul class='online'>"; while($row = mysql_fetch_assoc($sql)) { $usertime = strtotime($row['last_activity']); $difference = time() - $usertime; $idletime = 300; //3 Minutes echo $difference." is the difference<br/>"; echo $idletime." is the idletime<br/><br/>"; if($difference > 600) { echo $row['username']." is offline<br/>"; } else if($difference > 150) { $idletime++; echo $row['username']." is idle<br/>"; } else { echo $row['username']." is online<br/>"; } } ?> update.php <?php session_start(); include('dbconnect.php'); $username = $_SESSION['login']['username']; $sql = mysql_query("UPDATE users set last_activity = CURRENT_TIMESTAMP WHERE username = '$username'"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/154180-timestamp-always-starts-at-3600/ Share on other sites More sharing options...
asmith Posted April 15, 2009 Share Posted April 15, 2009 Probably the difference between your server time and your local computer is 1 hour. One of the sites I work on, the time there is 7:30 difference from my local. Quote Link to comment https://forums.phpfreaks.com/topic/154180-timestamp-always-starts-at-3600/#findComment-810523 Share on other sites More sharing options...
gaza165 Posted April 15, 2009 Author Share Posted April 15, 2009 Is there anyway I can get this to set it properly?? Quote Link to comment https://forums.phpfreaks.com/topic/154180-timestamp-always-starts-at-3600/#findComment-810533 Share on other sites More sharing options...
gffg4574fghsDSGDGKJYM Posted April 15, 2009 Share Posted April 15, 2009 It's all done using MySQL and PHP, since there all server script side they can't be any difference comming from local time. Some place you are using MySQL time other you use PHP time. My best guess is the MySQL and PHP aren't located on the same server. Usually PHP and MySQL server are physically near and they probably are in the same timezone. Maybe one of them is still on the daylight the other one not. Try that or use similar in a temporary table : <?php include('dbconnect.php'); $results = mysql_query("UPDATE users set last_activity = CURRENT_TIMESTAMP WHERE id=0;"); $results = mysql_query("SELECT last_activity FROM users WHERE id=0;"); $row = mysql_fetch_assoc($results); $usertime = $row['last_activity']; echo time()."<br>"; echo $usertime."<br>"; ?> If time() and $usertime are the same (maybe 1 or 2 seconds difference for the execution time), you will know what the server time is for MySQL and PHP. If both server should have same time and they haven't, contact your webhosting. Quote Link to comment https://forums.phpfreaks.com/topic/154180-timestamp-always-starts-at-3600/#findComment-810536 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.