14
我一直在使用mongojs驅動程序爲nodejs在mongodb中插入實際的日期時間對象時遇到問題。任何幫助?在mongodb中插入當前日期時間
var currentdate = new Date();
var datetime = currentdate.getDate() + "/"
+ (currentdate.getMonth()+1) + "/"
+ currentdate.getFullYear() + " @ "
+ currentdate.getHours() + ":"
+ currentdate.getMinutes() + ":"
+ currentdate.getSeconds();
db.test.update({
conversation: conv
},{
$push:{ messages: {
message: message,
pseudo: name,
current_date: datetime
}}
},{upsert: true});
只需插入'new Date()'? – Sammaye