Skip to content

Commit

Permalink
time zone by specifying the 'Asia/Kolkata'
Browse files Browse the repository at this point in the history
  • Loading branch information
truethari committed Jun 13, 2023
1 parent 66154cf commit 0e16406
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
3 changes: 2 additions & 1 deletion models/location.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Joi = require("joi");
const mongoose = require("mongoose");
const moment = require("moment-timezone");

const locationSchema = new mongoose.Schema({
lat: {
Expand All @@ -16,7 +17,7 @@ const locationSchema = new mongoose.Schema({
},
time: {
type: Date,
default: () => new Date(Date.now() + 5.5 * 60 * 60 * 1000),
default: () => moment().tz("Asia/Kolkata").toDate(),
},
});

Expand Down
3 changes: 2 additions & 1 deletion models/state.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Joi = require("joi");
const mongoose = require("mongoose");
const moment = require("moment-timezone");

const stateSchema = new mongoose.Schema({
speed: {
Expand All @@ -14,7 +15,7 @@ const stateSchema = new mongoose.Schema({

time: {
type: Date,
default: () => new Date(Date.now() + 5.5 * 60 * 60 * 1000),
default: () => moment().tz("Asia/Kolkata").toDate(),
},
});

Expand Down
20 changes: 20 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"cors": "^2.8.5",
"express": "^4.18.2",
"joi": "^17.9.2",
"moment-timezone": "^0.5.43",
"mongoose": "^7.2.3"
}
}

0 comments on commit 0e16406

Please sign in to comment.