Answer the question
In order to leave comments, you need to log in
How to fix time shift (MySQL query)?
The difference between local time (Open Server) and time on the server (VPS) is 3 hours. (on the server 3 hours less)
On the VPS server - do not change the time. But some of the settings are probably possible.
The server has a database with a table - table. The table has 2 columns - time and data.
time - unix timestamp. $time=time();
data is just a number.
I was told that records for the current day, the previous day (any number of days ago) - exactly from 00.00 to 24.00 can be displayed like this.
$result=mysql_query("SELECT `time`,`data` FROM `table` where `time`>UNIX_TIMESTAMP(SUBDATE(CURDATE(),1)) AND `time`<UNIX_TIMESTAMP(SUBDATE(CURDATE(),2))") or die (mysql_error());
Answer the question
In order to leave comments, you need to log in
when initializing the connection, execute the query "SET time_zone = '+2:00';" (or other appropriate time zone), in PHP, respectively, also set the time zone so that there is no discrepancy, there is no need to touch the OS settings.
Change the default-time-zone in the
mysql config
with a shift in the right direction
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question