以下是數據的JSON:MongoDB字符串到日期?
{
projectName: String,
projectDescription: String,
users: [
],
projectManager: [
],
teamLead: [
],
createdBy: String,
superAdmin: String,
createdAt: Date,
task: [
{
userID: String,
name: String,
taskName: String,
nohrs: Number,
description: String,
comments: String,
date: String,
from: String,
to: String,
lastUpdatedDate: String
}
]
}
任務的數組包含每個項目的許多任務。每個任務都有一個字符串格式的日期。我需要將每個字符串日期轉換爲ISO日期格式。 我們怎樣才能做到這一點? 我已經試過這樣:
db.projects.find({}).forEach(function(task){
task.date = new Date(task.date);
db.collection.save(task);})
但這添加一列日期,而不是編輯在任務數組中的日期?
可能的複製](http://stackoverflow.com/questions/32602220/mongo-db-remove-old-data-using-remove-command) – Yogesh
你的日期是怎樣的? – styvane