<?php
//echo phpinfo();die;
include('connectdb.inc.php');
//sleep(55);

date_default_timezone_set('Asia/Kolkata');
$sqlAD  = 'SELECT * FROM '.$DB->pre.'users WHERE isActive="1" AND userType="1" AND status="1"';
$AD = $DB->dbRows($sqlAD);
$currentTime = date('H:i:s');
$lotTime = date("h:i", strtotime("-15 minutes", strtotime(drawTimeCrone())));
if($currentTime >= "10:00" && $currentTime <= '21:46'){
	



	$sql = 'INSERT INTO '.$DB->pre.'key SET adminID="1",lotTime="'.$lotTime.'",dateAdded="'.date('Y-m-d h:i:s').'"';
	$DB->dbQuery($sql);
}


function drawTimeCrone(){
	global $DB;
	date_default_timezone_set('Asia/Kolkata');

$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 =  "$lotHour:$lotMin";
return $time_lot;
}


?>
