倒计时7小时然后显示确定

How can I countdown for 7 hours from a variable time (I will get time from my table which is inserted with timestamp), after 7 hours from variable time I will update a table.

I need something like that

$time = 2013-05-18 02:00:00 // comes from database
$target = $time + 7hours // time from database +7hours will be 2013-05-18 09:00:00
$until = $target - $time

I need something like below code

if ($until > 0 ) {
    echo "you need to wait for $until hours"
} else {
    echo "time is ok"; // i will update a table
}

Convert time into string using strtotime($time)+25200 where 7 hour =60*60*7=25200 sec and then check and also add this file to your cron job.

So, considering that $database_time is the stored time, in your db, and $time_now is your computers time, this message below, just echoed out:

You Must wait 4 hours right, now

It could be done much better, but still calculates the hours from now, to db and tells you how much more, you must wait :)

<?php
   $date = date_create();
   $database_time = '2013-05-18 22:00:00';
   $time_now =  date_format($date, 'Y-m-d H:i:s');

   $check =  $database_time[11];
   $check .=  $database_time[12];
   $check2 = $time_now[11];
   $check2 .= $time_now[12];

   $time_left =  $check - $check2;

So, here is how you can manage your ourputs

 if($time_left > 0) {
   echo "You Must wait $time_left  hours right, now"; 
 }else{
   echo "Time is OK";
 }