This is the top part of a script I am using for redirection. It connects to two txt based databases depending on time and redirects the user to a particular link. There are two databases 'db1.txt' and 'db2.txt', It should be using only the 'db2.txt' on Sundays. It should use the 'db1.txt' Monday-Saturday 9AM to 6PM and It should use the 'db2.txt' Monday-Saturday 6:01PM to 8:59AM but now here in India, time is 12.26AM, and it is still using 'db1.txt' instead of 'db2.txt' How to fix it ?
date_default_timezone_set('Asia/Kolkata');
$time = date("Hi", time());
##
if (date('N') !=7 && $time >= 0900 && $time <= 1800)
{
$db = "db1.txt";
}
else
{
$db = "db2.txt";
}
I believe your leading zeros are messing up the comparison, use this instead:
date_default_timezone_set('Asia/Kolkata');
$time = date("G");
##
if (date('N') !=7 && $time >= 9 && $time < 18)
{
$db = "db1.txt";
}
else
{
$db = "db2.txt";
}