Jump to content

Time problem


Greaser9780

Recommended Posts

<?

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.