Reputation: 95
I have a date field set with table.date('day');
in knex schema. When I insert it with knex('table_name').insert({ someOtherData, day: '2016-08-14'})
and then use knex.select('day').from('table_name')
I get [Date: 2016-08-13T22:00:00.000Z]
. It seems as if it saves it as '2016-08-14T00:00:00.000Z' and then subtracts 2 hours to conver it into UTC.
Upvotes: 2
Views: 646
Reputation: 1190
This issue may be because of time zone conversion. Have you tried using timestamp?
table.timestamp('response_deadline')
It will convert date datatype to timestamp with time zone.
Upvotes: 1
Reputation: 3622
the docs on schema building seems vague however try to deliver this date string to a js date constructor, i'm pretty sure it will deliver you the correct date.
it tries to represent every date as the specs recommends, that's why you're seeing the date this way.
Upvotes: 0