I am currently on a shared hosting plan, and MySql server timezone is set to System time which is not Indian (required for my application) timezone, And my application needs to use MySql queries with time operations such as NOW(), TIMEDIFF etc.
i have tried setting the global timezone of my server to india but i dont have this privilege to execute it in Shared hosting plan.
SET GLOBAL time_zone = '+05:30';
Though i can set the session timezone in mysql throgh
SET @@session.time_zone = '+05:30';
which just works fine and displays Indian current time.
In order to perform the mysql operation in my application is to use two queries (one set time and other my operation) combined and executed as one.
E.g. from my application executing queries and fetching result -
$userCheck = "SET @@session.time_zone = '+05:30';SELECT * FROM `entries` WHERE `d_timestamp` > NOW() AND DATE(`d_timestamp`) = DATE(NOW()) AND TIMEDIFF(TIME(`d_timestamp`), TIME(NOW())) > '00:59:00' ORDER BY modified DESC";
if ($show_userCheck = mysqli_query($db, $userCheck))
{
if((mysqli_num_rows($show_userCheck) > 0)){
// Some Stuff
}
}
But when it comes to fetch the result from 2nd Query through php, i see this php error:
mysqli_num_rows() expects parameter 1 to be mysqli_result, boolean given
When executed only as a single query (without the set timezone) it works well and fine, but have no idea till now how to deal with this situation.
Thanks in advance.