<meta http-equiv="refresh" content="0;<?php echo $_SERVER['PHP_SELF']?>">
<body style="background-color: rgb(255,224,192);">
<?php

date_default_timezone_set('Asia/Kolkata');
	header('Access-Control-Allow-Origin: *');

$date = time();

$lotMin = date("i", $date);
$lotHour = date("h", $date);
$lotSec = date("s", $date);
$ampm = date("A", $date);



if ($lotMin >= 0 && $lotMin < 15) {
    $lotMin = 15;
} else if ($lotMin >= 15 && $lotMin < 30) {
    $lotMin = 30;
} else if ($lotMin >= 30 && $lotMin < 45) {
    $lotMin = 45;
} else if ($lotMin >= 45 && $lotMin < 60) {
    $lotMin = 0;
    $lotHour++;
}

$lotHour = $lotHour % 12;
if ($lotHour == 0) {
    $lotHour = 12;
}

if ($lotHour < 10) {
    $lotHour = "0" . $lotHour;
}
if ($lotMin < 10) {
    $lotMin = "0" . $lotMin;
}
// if ($lotSec < 10) {
//     $lotSec = "0" . $lotSec;
// }

$time_lot = date("Y-m-d", $date) . " $lotHour:$lotMin:$lotSec";
$time_now = date("Y-m-d h:i:s", $date);

// $h = date("h", $date);
$m = $lotMin;
// $s = date("s", $date);

if ($m > 60) {
    $m = $m % 60;
    $h++;
    if ($m < 10) {
        "0" . $m;
    }
}

if ($time_lot == $time_now) {
    echo "Expired";
}
$drawTime = $lotHour.':'.$lotMin;

$sec_remaining =  (60 - date("s", time()));
if ($sec_remaining < 10) {
    $sec_remaining = "0" . $sec_remaining;
}

$min_remaining =  ((strtotime($time_lot) - strtotime($time_now)) / 60) - 1;
if ($min_remaining < 10) {
    $min_remaining = "0" . $min_remaining;
}
$time_remaining = $min_remaining . ":" . $sec_remaining;

//echo "Draw Time: " . $time_lot;
//echo "<br>Curr.. Time: " . $time_now;
//echo  $time_remaining.'-'.date('h:i',strtotime($drawTime)); 


 echo '<b style="margin-top:-10px;">'.$time_remaining.'</b>';


?>
</body>
