I am generating a report of orders broken down by date, month and year using the aggregate group function. My date is stored in the MongoDate object which is in UTC.
'$group' => array (
'_id' => array (
'year' => array ( '$year' => '$created' ),
'month' => array ( '$month' => '$created' ),
'day' => array ( '$dayOfMonth' => '$created' ),
)
)
I have tried adding to the date object using project, but it seems like I cannot add to a MongoDate Object. (As seen here: https://stackoverflow.com/a/18854229/1069277)
'$project' => array (
'created' => array (
'$add' => array (
'$created' => 8 * 60 * 60 * 1000
)
)
)
Is adding another field that stores with timezone corrected the only way to achieve this at this moment?