Uploaded image for project: 'Documentation'
  1. Documentation
  2. DOCS-9094

Comment on: "manual/reference/operator/aggregation/dateToString.txt"

    XMLWordPrintableJSON

Details

    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:

      { "createdAt" : ISODate("2016-03-11T00:05:18.816+08:00"), "day" : "2016-03-10" }

      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"?

      *

      Attachments

        Activity

          People

            Unassigned Unassigned
            joc98@163.com Wen Chen
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              7 years, 18 weeks, 6 days ago