Convert UTC dates to user specified timezone in mongoose in find query or while retriving

90 views
Skip to first unread message

vjo...@humancaresystems.com

unread,
May 4, 2018, 9:35:59 AM5/4/18
to Mongoose Node.JS ODM
Hi,

We have a requirement where we need to convert dates stored in mongodb to the user specified timezone while doing a find query or 
retrieving it.

This is applicable to all the dates. We are using nodejs / mongoose.

I tried to use aggregation projection datetostring but it doesnt seem to take effect.




Can anyone share how to achieve it. 


I tried below , which has no effect .Program is my Model.


Program.findById(req.params.programId,"-ae_config"/*, {"$expr": [{
"$project": {

date: { $dateToString: { "format": "%Y-%m-%d", date: "programStartDate", timezone: "America/New_York"} },



}
}]}*/).populate('roles').exec(function (err, program) {






Reply all
Reply to author
Forward
0 new messages