node.js - UTC DATE in Sequelize.js -
i'm using sequelize in node.js save open , close times. i'm using moment.js format. alter findorcreate i'm doing this:
result.open = moment(hours.open, "hh:mma").format("yyyy-mm-dd hh:mm:ss"); result.save() ...
this works fine , time gets formatted mysql's datetime format. problem when retrieve time seqquelize thinks it's utc time , converts est (my server timezone).
i prefer go database utc , come out same way. there i'm doing wrong? why sequelize not convert utc on insert assumes it's utc coming out? also, there way not have try convert server timezone?
i know pretty late here struggling postgres (maybe can point in right direction other engines)
as know postgres stores datetimes in utc.
the issue, me, turned out not in sequelize rather in pg
package.
in order fix it, place before sequelize = new sequelize()
line
var types = require('pg').types; var timestampoid = 1114; types.settypeparser(1114, function(stringvalue) { return new date( date.parse(stringvalue + "0000") ); });
the problem, think, pg
package doing new date(stringvalue)
, returns date in server's timezone, wrong (unless it's in utc itself)
for more info, please refer thread: https://github.com/brianc/node-postgres/issues/429
Comments
Post a Comment