mongodb - Why is my timezone conversion not working correctly when querying for events? -


i have mongodb query works fine on local machine, on production environment (heroku) doesn't work same way. example, in est timezone , production server returning events previous day if occur after 8:00 pm est (since there 4 hour offset utc). store of dates in utc format in mongodb database , conversion local timezone when querying data. once again, works fine on local testing environment. here query using:

event.find({     'starts': {        '$gte':moment(req.query.date+'t00:00:00.000').tz(req.user.tz).format(),         '$lte':moment(req.query.date+'t23:59:59.999').tz(req.user.tz).format()     }, }) .exec(function(err, data) {     if (err) {         console.log('error = ' + err);     } else {         return res.json(data);     } }); 

what doing wrong? made sure heroku app set utc. 1 other thing mongo database hosted through mongolab. suggestions appreciated.

i'm not sure if you're asking for, if want parse using specified time zone, then:

moment.tz(req.query.date,'yyyy-mm-dd',req.user.tz).format() 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -