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

Add time zone support, and %z and %Z arguments to the $dateToString operator

    • Fully Compatible
    • Query 2017-07-31

      The $dateToString operator is extended with the timezone argument. Its full new syntax is now:

          { $dateToString: {
              format: formatString,
              date: dateExpression,
              timezone: timeZoneIdentifier
          } }

      The timezone argument is optional. The "timezone" argument is optional, and must evaluate to specify an Olson Timezone Identifier such as "Europe/London" or "America/New_York", or, a UTC offset string in the forms: "+03", "-0530", and "+04:45". If present, it formats the string according to the given time zone, otherwise it uses UTC.

      The $dateToString format arguments have also been expanded. With the addition of the timezone argument came the %z and %Z format specifiers:

      The +hhmm or -hhmm numeric timezone as a string (that is, the hour and minute offset from UTC). Example: ``+0445``, ``-0500``

      The minutes offset from UTC as a number. Example (following the ``+0445`` and ``-0500`` from %z): ``+285``, ``-300``

            derick Derick Rethans
            ian@mongodb.com Ian Whalen (Inactive)
            1 Vote for this issue
            5 Start watching this issue