Node.js GraphQL时间戳与数据库不同
为什么graphql中显示的时间戳与数据库不同?例如,在我的数据库中,它显示2020-01-01 10:10:10。但在图表api i sh 2020-01-01T03:10:10.000Z中。我正在使用postgresql作为我的数据库。这是我的密码:Node.js GraphQL时间戳与数据库不同,node.js,postgresql,graphql,Node.js,Postgresql,Graphql,为什么graphql中显示的时间戳与数据库不同?例如,在我的数据库中,它显示2020-01-01 10:10:10。但在图表api i sh 2020-01-01T03:10:10.000Z中。我正在使用postgresql作为我的数据库。这是我的密码: const Notification = new graphql.GraphQLObjectType({ name: 'Notification', fields: () => ({ id: { type: graphq
const Notification = new graphql.GraphQLObjectType({
name: 'Notification',
fields: () => ({
id: { type: graphql.GraphQLInt },
platform: { type: graphql.GraphQLString },
action: { type: graphql.GraphQLString },
image: { type: graphql.GraphQLString },
title: { type: graphql.GraphQLString },
highlight: { type: graphql.GraphQLString },
bundle: { type: graphql.GraphQLString },
sender: { type: graphql.GraphQLString },
receiver: { type: graphql.GraphQLString },
status: { type: graphql.GraphQLString },
start_publish: {
type: GraphQLDateTime
},
end_publish: {
type: GraphQLDateTime
// resolve: (fields) => new Date(Date.UTC(fields.end_publish))
},
// team: {
// type: Team,
// sqlJoin: (playerTable, teamTable, args) => `${playerTable}.team_id = ${teamTable}.id` //innerjoin
// }
})
});
const QueryRoot = new graphql.GraphQLObjectType({
name: 'Query',
fields: () => ({
notifications: {
type: new graphql.GraphQLList(Notification),
resolve: (parent, args, context, resolveInfo) => {
return joinMonster.default(resolveInfo, {}, sql => {
return client.query(sql)
})
}
},
//...
})
})
最后,我设法用moment从前端设置了数据库。你的数据库是什么?@Alex:问题被标记为
postgresql
数据库中的数据类型是什么<代码>时间戳或时间戳
看起来时区转换正在进行,抱歉。我在你的代码中到处寻找它:-)我使用时间戳作为数据类型@a_horse_和_no_的名称