Organizational Research By

Surprising Reserch Topic

how to do query with timezone settings in mongodb

how to do query with timezone settings in mongodb  using -'mongodb,timezone'

I'm trying to transfer my application database from Mysql to Mongodb, but I met a problem with datetime queries.

In Mysql, when there is a datetime or timestamp column, you can set specific timezone for each request using command:

SET time_zone = timezone;
// do queries here

Is there any kind of similar solutions for this kind of demands?

I know applications can do the job after retrieving data from mongodb, but what about using aggregation with $hour, $month or $day operators?

asked Sep 21, 2015 by rajesh
0 votes

Related Hot Questions

2 Answers

0 votes

MongoDB stores all dates and times in UTC. This allows the timezone support and translation to be done application side instead of server side.

The best way to store dates and times is via the Javascript Date object. This will allow you to convert dates to and from Unix timestamps, using getTime() and Date(milliseconds).

It should be noted, that Javascript stores time in milliseconds since UNIX Epoch, whilst the standard UNIX timestamp is in seconds since Epoch.

answered Sep 21, 2015 by devkumargupta
0 votes

had a similar issue discussed here,!topic/mongodb-user/PodDGnWM09Q

also, this website also might come in handy for future refrencing :)

answered Sep 21, 2015 by 20shahi