I'm using Mongo's aggregation framework to convert dates to strings using the $dateToString method. It's changing the day though due to the timezone. What can I do to work around this?
Input: new Date("2016-04-19T00:00:00+1000") *Note the time offset changes depending on the item.
Output: "2016-04-18"
Desired Output: "2016-04-19"
Code:
dateString: { $dateToString: { format: "%Y-%m-%d", date: "$date" } }
Strangely using $substring also returns the same result...
dateString: { $substr: ["$date", 0, 10] }