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
https://forums.phpfreaks.com/topic/40802-time-problem/
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
https://forums.phpfreaks.com/topic/40802-time-problem/#findComment-197566
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.