【发布时间】:2015-10-26 01:09:05
【问题描述】:
我正在将日期添加到名为 Meals 的 Meteor 集合中。日期是用餐日期,当我刷新出版物时,它显示前一天作为用餐日期。餐点添加在 Meteor.method 中,包括:
// pick out the whitelisted keys
var item = {
name : postAttributes.name,
date : moment(postAttributes.date).utc().toDate(),
userId: user._id,
author: user.emails[0].address,
created: moment().toDate()
};
console.log(item.date)
var nameId = Meals.insert(item);
var meal = Meals.findOne(nameId);
console.log(meal)
console.log(item.date) 返回
Fri Nov 06 2015 00:00:00 GMT-0500 (Eastern Standard Time)
console.log(meal) 返回
_id: "vyrXkmRFsD5px7wFz"
author: "ellis.cs@gmail.com"
created: Sun Oct 25 2015 21:02:26 GMT-0400 (Eastern Daylight Time)
date: Fri Nov 06 2015 00:00:00 GMT-0500 (Eastern Standard Time)
name: "Tacos"
userId: "kyd9dMb9iCuRJTMhW"
但是,如果我立即做一个
Meals.find({name : "Tacos}).fetch();
返回
_id: "vyrXkmRFsD5px7wFz"
author: "ellis.cs@gmail.com"
created: Sun Oct 25 2015 21:02:25 GMT-0400 (Eastern Daylight Time)
date: Thu Nov 05 2015 19:00:00 GMT-0500 (Eastern Standard Time)
name: "Tacos"
userId: "kyd9dMb9iCuRJTMhW"
注意日期字段的差异。我在这里不知所措。
【问题讨论】:
标签: javascript date meteor momentjs