Note that there are some explanatory texts on larger screens.

plurals
  1. POphp time messed up
    primarykey
    data
    text
    <p>i need help creating a count down timer in php. the problem is that i want to store an INT in my database which is going to be seconds, and this int is going to be added to current time to represent the future time.</p> <p>now if i try to subtract the current time from future time to show how many seconds remaining, am getting wrong date.</p> <p>here is my schema</p> <pre> mysql> desc buildings; +-----------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(20) | YES | | NULL | | | level | int(2) | YES | | NULL | | | created | int(11) | NO | | NULL | | | finished | int(11) | YES | | NULL | | | player_id | int(11) | YES | MUL | NULL | | | position | int(2) | YES | | NULL | | +-----------+-------------+------+-----+---------+----------------+ </pre> <p>and heres the code to check</p> <pre> //starting session; //connecting to database; $query = "select created, finished from buildings where id = 1"; $query = mysql_query($query) or die ("could not query <br />".mysql_error() ); while($row = mysql_fetch_assoc($query)) { $created = $row['created']; $finished = $row['finished']; } $CurrentTime = time(); $status = $finished - $CurrentTime; $realstatus = date("H:i:s",$status); if($status > 0) { echo "under construction, still ".$realstatus." to finsih"; }else { die("construction complete"); } //echo $created."<br />".$finished; ?> </pre> <p>any help will be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload