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?
Overview. MongoDB stores times in UTC by default, and will convert any local time representations into this form. Applications that must operate or report on some unmodified local time value may store the time zone alongside the UTC timestamp, and compute the original local time in their application logic.
Yes, Mongo compass provides only filter option(Query Bar) to do queries on specific collection.
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.
had a similar issue discussed here, https://groups.google.com/forum/?fromgroups=#!topic/mongodb-user/PodDGnWM09Q
also, this website also might come in handy for future refrencing :) http://www.querymongo.com/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With