Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-29209

Add TZ support to the new $dateFromString A/F operator

    • Fully Compatible
    • Query 2017-07-10, Query 2017-07-31

      This features adds a new Aggregation Framework operator $dateFromString.

      It has the following syntax:

      { "$dateFromString": { "dateString": dateString, "timezone": timeZoneIdentifier } }
      

      The dateString could be anything like:

      • 2017-08-04T17:02:51Z
      • August 4, 2017 17:10:27.812+0100

      The "timezone" argument is optional, and can either specify an Olson Timezone Identifier such as "Europe/London" or "America/New_York", or, it can be a UTC offset in the forms: "+03", "-0530", and "+04:45". If you specify a timezone argument it means that the dateString that you provided will be interpreted as it was in that time zone.

      For example:

      { $dateFromString: { dateString: "2017-08-04T17:06:41.113", timezone: "Europe/London" } }
      

      Would mean 17:06 local time in London, or 16:06 in UTC (as London right now is at UTC+1).

      It is not allowed to specify a time zone through the dateString (such as the ending "Z" or "+0400") and also specify a time zone through the timezone argument. In that case, an exception is thrown.

            Assignee:
            derick Derick Rethans
            Reporter:
            derick Derick Rethans
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: