pq: datetime field is not returning UTC

For a table like:

CREATE TABLE times (
    typeId   bigint,
        datetime timestamp without time zone
);

It is not returning the correct datetime:

input:  &{0 2009-11-10 23:00:00 +0000 UTC}
output: &{0 2009-11-10 23:00:00 +0000 +0000}

Instead of returning UTC, it is adding other “+0000”.

I checked it in the original repository (https://github.com/bmizerany/pq), and it is working ok there.

About this issue

  • Original URL
  • State: closed
  • Created 11 years ago
  • Comments: 25 (17 by maintainers)

Most upvoted comments

I just solve it; the output is right now:

=== Driver "github.com/lib/pq"
+ DateTime
    input:  &{0 2009-11-10 23:30:10.123456789 +0000 UTC}
    output: &{0 2009-11-10 23:30:10.123457 +0000 UTC}
+ DateTime
    input:  &{2 2013-12-22 19:10:41.223715905 +0000 UTC}
    output: &{2 2013-12-22 19:10:41.223716 +0000 UTC}

I edited file ‘/etc/postgresql/9.1/main/postgresql.conf’ to change the value of the key “timezone” to “UTC”: timezone = 'UTC'

Then, I restarted the server: sudo /etc/init.d/postgresql restart

Thanks!