Details
-
Bug
-
Resolution: Won't Fix
-
Major - P3
-
None
-
None
-
mongo shell
*Location*: https://docs.mongodb.com/v3.0/reference/operator/aggregation/dateToString/
*User-Agent*: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36
*Referrer*: https://docs.mongodb.com/v3.0/reference/operator/aggregation-date/
*Screen Resolution*: 1920 x 1080
mongo shell *Location*: https://docs.mongodb.com/v3.0/reference/operator/aggregation/dateToString/ *User-Agent*: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36 *Referrer*: https://docs.mongodb.com/v3.0/reference/operator/aggregation-date/ *Screen Resolution*: 1920 x 1080
Description
$dateToString cannot get local date string.
Execute:
db.users.aggregate(
{$match: {createdAt: {$type: 'date'}}},
{$project: {_id: 0, createdAt: 1, day: {$dateToString: {format: '%Y-%m-%d', date: '$createdAt'}}}}
)
One of the results:
But I expected the "day" field could be "2016-03-11". In other words, I want to format the "createdAt" field with timezone.
Would you like to add an operator such as "$timezone"?
*