Reputation: 61
How can i change the timezone in the timestamp on mongoose? here i have my jobSchema:
model.js:
const jobSchema = new Schema({
owner: {
type: Schema.ObjectId,
ref: 'User',
required: true
},
title: {
type: String
},
description: {
type: String
},
tag: {
type: String
},
....
}, {
timestamps: true,
toJSON: {
virtuals: true,
transform: (obj, ret) => { delete ret._id }
},
toObject: { virtuals: true }
})
the result of the time is:
"createdAt": "2019-01-21T04:35:20.076Z"
but my actuall time is 11.35 am.
I want to change the timestamp TimeZone to GMT/UTC +7. is it possible to do this? if it possible, how can i do this? thanks.
Upvotes: 3
Views: 5121
Reputation: 9096
MongoDB stores date in UTC format always. However, you can convert it to your timezone yourself or mongoose-timezone to convert the dates in local timezone.
Upvotes: 2