Reputation: 663
I need to get day of month in mongo in local timezone. Now if i run
$dayOfMonth : ISODate("2017-10-19T00:00:00.000+01:00")
i get 18, but i need that in local timezone. Is there any way how to force mongo to use local timezone with $dayOfMonth
? Or at least how to get timezone offset in mongo?
Upvotes: 0
Views: 973
Reputation: 75964
You can try the below aggregation in 3.6 which adds the timezone support for all date operators.
db.collection_name.aggregate({
"dayOfMonth": {
"$dayOfMonth": {
"date": "$date",
"timezone": "Europe/Amsterdam"
}
}
})
Upvotes: 1