1
我遇到了一个问题,即在我的视图中将记录用作对象时,记录在我的数据库中的日期与代表的日期不匹配。我似乎无法弄清楚为什么记录会有不同的表现,但我注意到在我的数据库中,日期与yyyy-mm-dd
格式中的日期一致,时间戳为00:00:00
,e.x. 2015-12-26 00:00:00
。这是它应该保存的正确格式。出于某种原因,当我显示该值时,它会以Fri Dec 25 2015 19:00:00 GMT-0500 (EST)
的格式显示,并且日期比后面的日期晚,因为它正在记录并显示格林尼治标准时间(GMT),比落后5小时这是有道理的,为什么这两个不匹配。我没有看到它在我的模型或路线中设置的位置。解决这个问题的任何帮助?将不同于模型对象的续集DATE记录
AnnotationDate是我引用
这里列是我的模型:
appRoutes.route('/')
.get(function(req, res){
models.Annotation.findAll({
where: {
userId: req.user.user_id
},
attributes: ['annotationId', 'annotationDate'],
order: 'annotationDate DESC'
}).then(function(annotation){
res.render('pages/test.hbs',{
annotation: annotation,
user: req.user,
message: req.flash('Flash is back!')
});
})
})
.post(function(req, res){
models.Annotation.create({
annotationDate: req.body.annotationDate,
userId: req.user.user_id
}).then(function() {
res.redirect('/app');
}).catch(function(error){
res.send(error);
})
});