I have stored in the database the date of adding any object, and, moreover, it is stored in UNIX format. The user sees the date in the format (Day-month-year), that is, without time. In my project, the correct and correct date is very important.
But there is one problem. For example, one user added the date 04/22/2018 00:00 (GMT). Suppose a user say from Ukraine requested this date (04/22/2018 00:00). All is well, but his request also needs to be translated to GMT. And it turns out that the date will go to the sql query (04/21/2018 21:00). I repeat, all operations with dates occur through their transfer to unix time.
Ultimately, the user from Ukraine will not see the object on the requested date, although he requested it.
I have lost all understanding how to translate these dates and how to work with time zones.
|
1 answer
Users add data to the database not through a direct connection to the database, but most likely through the site, right? That is, the script for adding / retrieving data works with the same time zone (which is on the server and not on the visitor’s watch), there should be no discrepancies. Well, when adding / extracting there are ways to specify the time zone - use always one in the scripts and everything will be fine.
|