Search code examples
phpmysqlcountdown

Countdown for 7 hours then show ok


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
}

Solution

  • 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.