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);
})
});