When I run:
psql great_dev -c 'show timezone'
The following is returned:
TimeZone
------------
US/Eastern
(1 row)
I want the timezone to be EST, so I think that is correct. The problem is that whenever I run some kind of database operation (IE update_attributes, save etc.), the timestamps are in UTC like this:
SQL (0.6ms) UPDATE "schedules" SET "accepted" = $1, "updated_at" = $2 WHERE
"schedules"."id" = 46 [["accepted", "only_freelancer"],
["updated_at", Mon, 02 Dec 2013 16:51:07 UTC +00:00]]
I am starting to implement several background jobs and it is essential that I understand what timezone Postgres is in.
The default timestamp
type in Postgres is timestamp without time zone
.
To deal with this, employ the data type timestamp with time zone
.
Or run your database with the time zone set to UTC and use timestamp [without time zone]
.
Be aware that the time zone setting of the session is relevant to what Postgres actually returns for your queries.
This related answer provides all the details you might need:
Ignoring timezones altogether in Rails and PostgreSQL