Answer the question
In order to leave comments, you need to log in
How to account for time difference when working with timezones in php and sql?
Good day! I work with a reporting system. I ran into a problem when fetching data from the database taking into account time zones.
The server works according to Moscow time.
When writing data to the database, the client can set the date and time of the recording, the record is inserted not the one that the client specified, but is transferred to the Moscow time zone, and the client is already displayed in his time zone.
For example:
The client made an entry on 2019-02-10 at 00:01:55 Ekaterinburg time UTC+5, and 2019-02-09 22:01:55 Moscow UTC+3 was recorded in the database, then the client wants to receive all records for 2019 -02-10 and makes sql query
"SELECT * FROM parcel WHERE DATE(date_added) >= '2019-02-10' AND DATE(date_added) <= '2019-02-10'";
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question