Infinitive Posted February 11, 2009 Share Posted February 11, 2009 My site needs to be able to mark an event X hours in the future, then indicate how much time is left until that event, and ultimately note when it's passed. There are other considerations but that's the gist of the current concern. I use ADDDATE in and strtotime() out. Straightforward except for daylight savings time. Test code like this: $setSQL = " UPDATE Test_Table SET FutureTime = ADDDATE(now(), INTERVAL 1334 HOUR) WHERE UserID = 0"; $Result1 = mysql_query($setSQL) or die(mysql_error()); $query_Check = " SELECT FutureTime, now() as Current FROM Test_Table WHERE UserID = 0"; $check = mysql_query($query_Check) or die(mysql_error()); $row_check = mysql_fetch_assoc($check); $then = strtotime($row_check['FutureTime']); $now = strtotime($row_check['Current']); echo "difference is " . ($then - $now) / 60 / 60; And that clearly demonstrates the problem because I set interval of 1334 but get back 1333. Now broadly speaking I suspect there are a few ways to solve this. But I'm not knowledgeable enough to weigh them. So I would appreciate some advice on how you would fix this contradiction. As I say there are a number of variations on this. Occasionally I want to compare to a manually-set system event and so I use mktime() without a db call, and it would be nice if the method here and the method there were compatible. But perhaps not essential? Anyway, whatever you think would be the simplest / most flexible solution I'd appreciate hearing. If it matters, the server in question is a VPS so I believe I can control system time but not hardware time. Link to comment https://forums.phpfreaks.com/topic/144792-php-uses-savings-time-mysql-does-not/ Share on other sites More sharing options...
Infinitive Posted February 12, 2009 Author Share Posted February 12, 2009 Anyone have a suggestion? Link to comment https://forums.phpfreaks.com/topic/144792-php-uses-savings-time-mysql-does-not/#findComment-760312 Share on other sites More sharing options...
Q695 Posted February 12, 2009 Share Posted February 12, 2009 try this to get the server time, and base it off that: $_SERVER[''REQUEST_TIME''] Link to comment https://forums.phpfreaks.com/topic/144792-php-uses-savings-time-mysql-does-not/#findComment-760338 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.