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:

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

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

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

              Created:
              Updated:
              Resolved: