Thursday 20 April 2017

Knex with Postgres storing timestamp in unintended ways

I am using Knex query builder with Postgres in my application. I am trying to add a created_at and updated_at fields in my database with ISO8016 formatted data in UTC time. I am trying to have my data look like this:

2017-04-20T16:33:56.774Z

In my Knex migrations, I have tried using both the .timestamps() method creating both created_at and updated_at manually with the .timestamp() method and naming them myself.

When I seed my database and set created_at and updated_at equal to moment().utc().toISOString(), but it stores in my database as this:

2017-04-20 11:20:00.851-05

There is something between the code and the database changing the data and I don't know if it's Knex, the Postgres Node library, or Postgres itself.



via lgh

No comments:

Post a Comment