Fork me on GitHub
#sql
<
2018-01-14
>
jgh23:01:17

im seeing a weird issue when inserting dates into postgresql…. i’m using clj-time to parse dates in the format yyyy-MM-dd and coerce to sql time…i print out that object and it appears correct (eg. 2018-01-02 ends up as #inst "2018-01-02T00:00:00.000000000-00:00"), however somewhere between clojure and postgresql the timezone ends up…elsewhere.

jgh23:01:35

inserting that value manually using psql gives the right result

jgh23:01:10

looks like the time ends up as 2018-01-01T05:00:00Z

seancorfield23:01:08

What is the data type of the column in your DB @jgh?

seancorfield23:01:00

Also, is your DB local or on another server? Are the timezones the same between your JVM/application and your PostgreSQL server?

jgh23:01:13

im just running it locally, but see the same issues on the server

jgh23:01:25

im in EST and just running it via docker on mac

seancorfield23:01:33

clj-time is going to give you a UTC date/time so that is your problem.

jgh23:01:11

the strange thing is i see this on the server that is in utc time too

seancorfield23:01:05

You need the server on UTC and the JVM and the database -- those can be separate settings -- and the client app that is talking to the DB also needs to be in UTC.

jgh23:01:14

is there a way of just forcing postgres to deal in UTC?

seancorfield23:01:15

Timezones suck :):