这是使用create()创建一条信息,返回的数据
{
comment_number: 0,
like: 0,
is_author: 0,
trash: 1,
id: 15,
forum_id: 1,
content: '地球不一直是圆的吗',
user_id: 13,
update_time: 2021-11-18T08:29:18.674Z,
create_time: 2021-11-18T08:29:18.674Z
}
这是使用查询方法返回的数据
{
id: 15,
user_id: 13,
forum_id: 1,
content: '地球不一直是圆的吗',
comment_number: 0,
like: 0,
is_author: 0,
create_time: '2021-11-18 16:29:18',
update_time: '2021-11-18 16:29:18',
trash: 1
}
config.sequelize = {
dialect: 'mysql',
host: '127.0.0.1',
port: 3306,
username: 'xxx',
password: 'xxx',
database: 'xxx',
timezone: '+08:00', // 保存为本地时区
dialectOptions: {
dateStrings: true,
// typeCast: true,
typeCast(field, next) {
// for reading from database
if (field.type === 'DATETIME') {
return field.string();
}
return next();
},
},
};
在sequelize配置中已经更改过时区了,为什么新建和查询出来时间还是不一样?需要怎么做才能解决这个问题呢?