Nath
Nath

Reputation: 6864

Saving date/time using mongomapper

Im trying to save date time information to the following field in mongo

key :last_comment_time_cache, DateTime

update_attributes!({:last_comment_time_cache => Time.now}) 

The data that is being saved is missing the time

"last_comment_time_cache": {
    "$date": "2013-03-23T00:00:00.000Z"
}

Any ideas on what im doing wrong?, Thanks Nath

Upvotes: 3

Views: 615

Answers (1)

fmendez
fmendez

Reputation: 7338

Try changing the field type to Time instead of DateTime. If you watch their Date extension here (Date is the parent of DateTime) they are only taking day,month and year into account to construct the date that will be sent to mongo, that's not the case for their Time implementation.

Upvotes: 4

Related Questions