Mongo not storing unix timestamp properly [closed] Mongo not storing unix timestamp properly [closed] mongoose mongoose

Mongo not storing unix timestamp properly [closed]


The unix() method returns the seconds since the Unix epoch, but MongoDB uses the JavaScript style of milliseconds since the epoch.

It's best to just get the JavaScript Date object that moment wraps using toDate():

Service.user.updateMyDate({myDate: moment().toDate()});