0

I'm notice that when I replicate data between 2 server with different time zone, the time data in PostgreSQL is shifted when I load it to a client (in my case, a Rails console). I thought all persisted data should be converted to UTC but it doesn't seem to be the case.

Is there any thing to config when setting up replication so the time wouldn't mess?

  • Is the data type timestamp or timestamp with time zone (timestamptz)? Rails should really be setting TimeZone to UTC for each connection. – Craig Ringer Aug 15 '14 at 0:58
  • It's datetime – Phuong Nguyen Aug 15 '14 at 3:59
  • That isn't a postgresql type. What is the database type it is mapped to? – Craig Ringer Aug 15 '14 at 4:41
  • Sorry, it's mapped to timestamp without time zone – Phuong Nguyen Aug 15 '14 at 9:12
  • In that case I suggest changing the PostgreSQL timezone, if Rails doesn't do so its self. timestamp without time zone is a time in local time. So if the local time is different, then .... so is the timestamp. – Craig Ringer Aug 15 '14 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.