Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>What you're asking for is currently being discussed in <a href="https://jira.mongodb.org/browse/SERVER-6310" rel="nofollow noreferrer">MongoDB issue SERVER-6310</a>.</p> <p>I found this in a link from <a href="https://groups.google.com/d/msg/mongodb-user/lMwSiqEJjmw/T8sPqIyu1zoJ" rel="nofollow noreferrer">a discussion thread</a>.</p> <p>The problem is common for any grouping by date, including SQL databases and NoSQL databases. In fact, I recently addressed this head on in RavenDB. There is a good description of the problem and a RavenDB solution <a href="http://ravendb.net/kb/61/working-with-date-and-time-in-ravendb#time-zone-conversions" rel="nofollow noreferrer">here</a>.</p> <p>The MongoDB issues discusses a workaround, which is similar to what I described in comments above. You precalculate the local times you are interested in, and group by those instead.</p> <p>It will be difficult to cover every time zone in the world with either approach. You should decide on a small handful of target zones that make sense for your user base, such as the per-office approach I described in the RavenDB article.</p> <p><strong>UPDATE: This issue was solved in MongoDB in July 2017 (version 3.5.11).</strong> The solution is described in the first link above, but in short they have introduced a new object format for dates in aggregation expressions: <code>{ date: &lt;dateExpression&gt;, timezone: &lt;tzExpression&gt; }</code> that allows you to specify a timezone to use when aggregating. See <a href="https://docs.mongodb.com/manual/reference/operator/aggregation/hour/" rel="nofollow noreferrer">here</a> for another example in the Mongo docs.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload