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. Link to comment https://forums.phpfreaks.com/topic/40071-trouble-with-remaining-time-display/ 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(); Link to comment https://forums.phpfreaks.com/topic/40071-trouble-with-remaining-time-display/#findComment-193803 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? Link to comment https://forums.phpfreaks.com/topic/40071-trouble-with-remaining-time-display/#findComment-193813 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. Link to comment https://forums.phpfreaks.com/topic/40071-trouble-with-remaining-time-display/#findComment-193817 Share on other sites More sharing options...
Greaser9780 Posted February 25, 2007 Author Share Posted February 25, 2007 TYVM will try it shortly. Link to comment https://forums.phpfreaks.com/topic/40071-trouble-with-remaining-time-display/#findComment-193819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.