I am creating a online examination portal where the students get a total of 3 hrs to answer the question , i want to save the value of the countdown timer in the database so that if there is a power failure then the timer can again start from the last saved value
You should track the date when the timer starts (which can be a mysql datetime column) and now you can calculate the time which is past.
Here an example for calculate the time:
<?php
// load the date from the database
$timeDate = strottime($data['created_at']);
$now = time();
$diff = $now - $timeDate;
// $diff is now an \DateInterval
if ($diff > 10800) { // If the difference more than 3 hours
// show some errors or do whatever you want :)
}