MongoDB
 SQL >> Database >  >> NoSQL >> MongoDB

Formattare le date nell'output della shell di MongoDB

Usa una pipeline di aggregazione con $dateToString per formattare i campi data:

db.getCollection('people').aggregate([ { $project:{ datetime: {$dateToString: {format: "%G-%m-%d %H:%M:%S",date: "$datetime"}}, age : 1 } } ]);