-
Type: Question
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.6.0, 3.6.13
-
Component/s: None
-
None
A specific AMI/repo results in a MongoDB deployment returning "unrecognized time zone identifier" for the command "db.test.aggregate([{$project: {"hour": {$hour:{date: "$dt", timezone:"Etc/GMT+7"}}}}])". The command works fine on many other 3.6.13 installations/instances.
This reproduces using:
- An AWS instance in eu-west-1 launched using image amzn-ami-hvm-2016.03.3.x86_64-gp2 (ami-f9dd458a)
- A /etc/yum.repos.d/mongodb-org.repo file with the following contents:
[mongodb-org-3.6] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/amazon/2013.03/mongodb-org/3.6/x86_64/ gpgcheck=1 enabled=1 gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc
- A mongod installed/started using:
sudo yum install -y mongodb-org service mongod start
- The following shell commands:
> db.test.insert({dt: new ISODate()}) WriteResult({ "nInserted" : 1 }) > db.test.aggregate([{$project: {"hour": {$hour:{date: "$dt", timezone:"Etc/GMT+7"}}}}]) assert: command failed: { "ok" : 0, "errmsg" : "unrecognized time zone identifier: \"Etc/GMT+7\"", "code" : 40485, "codeName" : "Location40485" } : aggregate failed _getErrorWithCode@src/mongo/shell/utils.js:25:13 doassert@src/mongo/shell/assert.js:16:14 assert.commandWorked@src/mongo/shell/assert.js:403:5 DB.prototype._runAggregate@src/mongo/shell/db.js:260:9 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1212:12 @(shell):1:1 2019-07-17T18:49:22.777+0000 E QUERY [thread1] Error: command failed: { "ok" : 0, "errmsg" : "unrecognized time zone identifier: \"Etc/GMT+7\"", "code" : 40485, "codeName" : "Location40485" } : aggregate failed : _getErrorWithCode@src/mongo/shell/utils.js:25:13 doassert@src/mongo/shell/assert.js:16:14 assert.commandWorked@src/mongo/shell/assert.js:403:5 DB.prototype._runAggregate@src/mongo/shell/db.js:260:9 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1212:12 @(shell):1:1
original description
Hello! I was trying to make a project like this:
{ { $project: { hour:{$hour:{date:'$eventCreatedAt',timezone:'$timezone'}} } },
where $eventCreatedAt is always an ISODate and $timezone can be any standard timezone from https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
I saw that when the timezone is Etc/GMT+7 mongo throws an exception saying it is not recognized.
I have read the documentation which states that the recognized timezones are:
- an Olson Timezone Identifier, such as "Europe/London" or "America/New_York", or
- a UTC offset in the form:
- +/-[hh]:[mm], e.g. "+04:45", or
- +/-[hh][mm], e.g. "-0530", or
- +/-[hh], e.g. "+03".
My question is why there not supported all standard timezonez such as Etc/GMT+7 ? All programming languages supports them so mongo why not? In the end that is a standard and shoul be completely covered.
- duplicates
-
SERVER-59701 Error when working with some timezones when using external timezones database
- Closed