Created
January 29, 2014 16:52
-
-
Save jwage/ae2e3e2c4a5927daa19d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// works in production | |
core:PRIMARY> db.test.insert({test:new Date('2014-01-29 03:00')}) | |
core:PRIMARY> db.test.find().pretty() | |
{ | |
"_id" : ObjectId("52e930ef400853587d69153f"), | |
"test" : ISODate("1970-01-01T00:00:00Z") | |
} | |
// does not work in other dev/local envs | |
> db.test.insert({test: new Date('2014-01-29 03:00')}) | |
> db.test.find().pretty() | |
{ | |
"_id" : ObjectId("52e931403aac5af45aa48fd5"), | |
"test" : ISODate("2014-01-29T09:00:00Z") | |
} | |
We're running 2.2.4 on all environments. |
@jwage: If it wasn't clear, I think the reason you saw a discrepancy was all to do with people running newer mongo
shells, even if the dev environment itself was 2.2.4. The above tests had nothing to do with the server version, since we need to create an ISODate object long before we send anything over the wire, and that happens with the client's JS interpreter.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"2014-01-29 03:00"
is not a valid argument to JavaScript's Date constructor. I assume that's the documentation for SpiderMonkey, which is what 2.2.x uses.I'm using
0
for January, since indexing starts at zero. 2.4.9 and 2.5.x have the same results, but they seem to be more flexible with parsing single string arguments:This may be relevant: http://code.google.com/p/v8/source/browse/trunk/src/date.js#156