$ date Thu Nov 17 17:53:26 MSK 2016 This is true, that is, on the OS side, everything is in order. Then it is specifically PostgreSQL.
Time in the records of the tables is 3 hours behind. How to fix it?
$ date Thu Nov 17 17:53:26 MSK 2016 This is true, that is, on the OS side, everything is in order. Then it is specifically PostgreSQL.
Time in the records of the tables is 3 hours behind. How to fix it?
In PostgreeSQL, the time and timestamp types can be declared as time zone sensitive.
timestamp with time zone never taking into account
timestamp without time zone or simply
timestamp If the field is declared as taking into account the time zone, then when writing data to the table, the time is recorded in UTC based on the current time zone of the user, and is given in local time, again based on the current time zone of the user.
If the time zone is not taken into account, then no manipulations with time are made. What is recorded, then read.
You can change the current user's time zone by setting the TIMEZONE parameter for a user session.
Specifically, in my case, the database was used in the RoR project and, as @spopovru suggested, it was enough to specify the Time Zone in the RoR configuration. After that, time was displayed on the site as it should.
This approach is still good because you can allow users to change the time zone (city) to their own, then the site will display the time for the user.
Source: https://ru.stackoverflow.com/questions/592298/
All Articles