I am interested in getting a timezone offset in my MongoDB Date field. Using MongoDB 2.4.9 on one machine, I see the following which is the correct way the Date should be stored:
NOVUSNYCLK67(mongod-2.4.9) test_salat> db.scala_date_test_1.find().toArray()
[
{
"_id": ObjectId("5329bf52e4b089adba4e75ec"),
"_typeHint": "com.novus.salat.test.model.Neville",
"ennui": true,
"asOf": ISODate("2014-03-19T12:01:22.355-0400")
}
]
Note the "-0400" fragment of the ISODate() here. On another machine, it looks like the following (wrong way):
> db.scala_date_test_1.find().toArray()
[
{
"_id" : ObjectId("5329c755c026b6d16dc5972b"),
"_typeHint" : "com.novus.salat.test.model.Neville",
"ennui" : true,
"asOf" : ISODate("2014-03-19T16:35:33.474Z")
}
]
I'm using Mongoid to persist these dates, but in reality, I just want to know how to get the timezone offset in my Dates so they are formatted like the following:
"asOf": ISODate("2014-03-19T12:01:22.355-0400")
and NOT like:
"asOf" : ISODate("2014-03-19T16:35:33.474Z")
Thank you for the help.