Timestamp is being changed in MongoDB after insertion

128 vues
Accéder directement au premier message non lu

dk9389

non lue,
8 sept. 2015, 03:08:5508/09/2015
à mongodb-user
Hi Guys,

While inserting date in MongoDB timestamp for the date is being changed.
I am inserting below record

db.test.insert({"datetime":new Date("2015-08-25 10:28:25.33")})

and it gets inserted in MongoDB as { "_id" : ObjectId("55ee83f94f01f37b95240f9c"), "datetime" : ISODate("2015-08-25T14:28:25.330Z") }
4 hours are being added to the timestamp. Can someone help me in finding the cause and solution for the same.

Derick Rethans

non lue,
8 sept. 2015, 05:03:2808/09/2015
à mongodb-user
You are inserting time in *local* time, whereas MongoDB stores things in
*UTC* time. The "Z" at the end of the string in ISODate() says so.
Presumably, you're on a timezone that's 4 hours offset of UTC/GMT.

cheers,
Derick

--
{
website: [ "http://mongodb.org", "http://derickrethans.nl" ],
twitter: [ "@derickr", "@mongodb" ]
}

dk9389

non lue,
8 sept. 2015, 09:17:3208/09/2015
à mongodb-user
Thanks Derick,

We are facing one more issue, We are inserting data in our MongoDB production server which is in UTC time zone, the server on which application is running to insert data is in "UTC-05:00" time zone. Ideally, the timestamp in MongoDB server after insertion should be the actual timestamp +5 hours. But what we are getting is actual timestamp +4 hours. 

Asya Kamsky

non lue,
9 sept. 2015, 19:49:0909/09/2015
à mongodb-user
Sounds like maybe the application machine isn't configured for
daylight savings time correctly?

Asya
> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user"
> group.
>
> For other MongoDB technical support options, see:
> http://www.mongodb.org/about/support/.
> ---
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to mongodb-user...@googlegroups.com.
> To post to this group, send email to mongod...@googlegroups.com.
> Visit this group at http://groups.google.com/group/mongodb-user.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/mongodb-user/50caaecd-4632-4b63-862e-933d9d997966%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.
Répondre à tous
Répondre à l'auteur
Transférer
0 nouveau message