Greaser9780 Posted March 2, 2007 Share Posted March 2, 2007 <? include("db.php"); $blah=mysql_query("SELECT time,exptime FROM time "); $rst=mysql_fetch_array($blah); $n= time(); $t = strtotime($rst['exptime']); $disp=$t - $n; echo date("G:i:s",$disp) ; ?> That is my code to display how much time is left. If I echo the time now it is correct. If I echo $t it matches the db. Can anyone tell me why $t-$n is always positive 16 extra hours over what it should be? Quote Link to comment Share on other sites More sharing options...
Jessica Posted March 2, 2007 Share Posted March 2, 2007 Your server and database might be set to different timezones? Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 2, 2007 Author Share Posted March 2, 2007 How do I correct for the 16 hour difference? $t-$n-57600 Quote Link to comment Share on other sites More sharing options...
Jessica Posted March 2, 2007 Share Posted March 2, 2007 looks fine to me. How are you inserting the expiration time? It will help if you make sure all of the time functions are handled on one side or the other. Instead of using now() in mysql, use PHP's time and format it. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted March 2, 2007 Author Share Posted March 2, 2007 I was using INSERT now() + INTERVAL 5 MINUTE Since I added the -57600 it appears to be working properly. I am only showing hours,minutes, seconds though Now I am having trouble getting the cronjob timer to work right since it never displays a negative number. I change the CRON script to if $disp >300 <-----number of seconds in 5 minutes. The timer should stay close to 5 minutes Quote Link to comment 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.