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

Javascript Date.getDate() does timezone conversion to server's local timezone

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Works as Designed
    • Affects Version/s: 2.1.1
    • Fix Version/s: None
    • Component/s: JavaScript
    • Labels:
      None
    • Environment:
      OS X 64bit server with local timezone anything other than UTC
    • Operating System:
      ALL

      Description

      If you use the Date.getDate() function (returns day of month, 1-indexed) in server-side javascript, it seems that timezone conversion into the server's timezone is taking place (here with server in US/Eastern timezone):

      > db.eval("function(){ return new ISODate('2012-05-07T00:00:00Z').getDate(); }")
      6
      > db.eval("function(){ return new ISODate('2012-05-07T12:00:00Z').getDate(); }")
      7
      > db.eval("function(){ return new ISODate('2012-05-07T23:00:00Z').getDate(); }")
      7

      Note that the local shell has the same behavior:

      > new ISODate('2012-05-07T00:00:00Z').getDate()
      6
      > new ISODate('2012-05-07T12:00:00Z').getDate()
      7
      > new ISODate('2012-05-07T23:00:00Z').getDate()
      7

      I can't tell whether I think the shell ought to do this conversion or not. The server certainly shouldn't.

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            dcrosta Daniel Crosta
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: