【发布时间】:2020-02-24 13:05:17
【问题描述】:
您好 Stackoverflow 团队,
我想知道,如何为时间戳设置时区 +01:00,我可以使用中性 utc 时区调用所有数据条目...但我想提供默认时区 +01:00 Europe Berlin .
即使当我调用我的数据库表时,我也希望得到正确的响应。非常感谢您的回答..
const Sequelize = require('sequelize');
//CREATE DATABASE tai;
const sequelize = new Sequelize('tai', 'postgres', '', {
//username: 'root',
//password: 'root',
dialect: 'postgres',
logging: false,
//storage: "./database.sqlite3",
host: 'localhost',
dialectOptions: { useUTC: false },
typeCast: function (field, next) { // for reading from database
if (field.type === 'DATETIME') {
return field.string()
}
return next()
},
timezone: '+01:00',
pool: {
max: 2,
min: 0,
acquire: 10000,
idle: 10000
}
});
【问题讨论】:
标签: node.js postgresql sequelize.js