Skip to content Skip to sidebar Skip to footer

Mongodb Date In Timezone

Is there a way to store Dates in local timezone and not in UTC ? This is my schema : var WhispSchema = new mongoose.Schema({ text : String, pos : {latitude: Number, longitu

Solution 1:

No, the BSON Date data type that's used within MongoDB to store dates is defined as a UTC datetime.

But this is really for the best, as storing datetimes in other time zones can get really messy. It's better to convert the stored UTC timestamps to a local timezone as needed after getting it from the database.

See this question regarding ways to do this within an aggregate pipeline.

Post a Comment for "Mongodb Date In Timezone"