Greaser9780 Posted February 25, 2007 Share Posted February 25, 2007 At this point I don't even know what type to set my field to in my table. I have a table where I keep a value"expirytime". I have tried TIME,DATETIME,TIMESTAMP and get nothing but an undesireable result. Here is my code for the script that displays time remaining in minutes and seconds: <?php include("db.php"); $blah=mysql_query("SELECT exptime FROM time "); $rst=mysql_fetch_array($blah); $n= time(); $t=$rst["exptime"]; $disp=$t - $n; echo $t ; echo"<br>"; echo $n; echo"<br>"; $minutes = floor($disp /3600); echo date("i:s",$minutes) ; include("login.php"); ?> I think the main problem is I can't seem to get $n and $t to be displayed in the same format. I banged my head against the wall for hours last night. Any help is greatly appreciated. Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 25, 2007 Share Posted February 25, 2007 When you store it as one of those you need to use strtotime() on it in order to convert it to a PHP timestamp, which you can then do math with, and use in date(); Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 25, 2007 Author Share Posted February 25, 2007 So when I enter the field for expiry time it should be exptime=strtotime() + INTERVAL 5 MINUTE IS that correct? Quote Link to comment Share on other sites More sharing options...
Jessica Posted February 25, 2007 Share Posted February 25, 2007 No, when you remove it you need to do $time = strtotime($rst['exptime']); It's a PHP function. Not MySQL. Quote Link to comment Share on other sites More sharing options...
Greaser9780 Posted February 25, 2007 Author Share Posted February 25, 2007 TYVM will try it shortly. 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.