14
Tôi đã gặp sự cố khi chèn một đối tượng datetime thực tế trong mongodb bằng cách sử dụng trình điều khiển mongoj cho nút jj. Bất kỳ giúp đỡ?Chèn ngày giờ hiện tại vào 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});
chỉ cần chèn 'Ngày mới()'? – Sammaye