I have Ubuntu 20.04 server with MongoDB 5.0 installed and running by official tutorial. I encountered problem with some timezones, for example Etc/UTC timezone. I get the error "unrecognized time zone identifier":
> db.data.insert({ dt: new ISODate() })
WriteResult({ "nInserted" : 1 })
> db.data.aggregate([
... {
... "$project": {
... "dtTimezone": {
... "$dateToString": {
... "date": "$dt",
... "timezone": "Etc/UTC"
... }
... }
... }
... }
... ])
uncaught exception: Error: command failed: {
"ok" : 0,
"errmsg" : "PlanExecutor error during aggregation :: caused by :: unrecognized time zone identifier: \"Etc/UTC\"",
"code" : 40485,
"codeName" : "Location40485"
} with original command request: {
"aggregate" : "data",
"pipeline" : [
{
"$project" : {
"dtTimezone" : {
"$dateToString" : {
"date" : "$dt",
"timezone" : "Etc/UTC"
}
}
}
}
],
"cursor" : {
},
"lsid" : {
"id" : UUID("24a0ca58-6d03-4827-b59c-4bd82ddf9976")
}
} on connection: connection to 127.0.0.1:27017 : aggregate failed :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
doassert@src/mongo/shell/assert.js:18:14
_assertCommandWorked@src/mongo/shell/assert.js:719:17
assert.commandWorked@src/mongo/shell/assert.js:811:16
DB.prototype._runAggregate@src/mongo/shell/db.js:276:5
DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1058:12
@(shell):1:1
At the same time, when using Europe/London, everything works:
> db.data.aggregate([
... {
... "$project": {
... "dtTimezone": {
... "$dateToString": {
... "date": "$dt",
... "timezone": "Europe/London"
... }
... }
... }
... }
... ])
{ "_id" : ObjectId("611832f076340952c425ce80"), "dtTimezone" : "2021-08-14T22:17:36.349Z" }
I found similar problem, but the solution was to comment "processManagement.timeZoneInfo" option and use internal timezones database. I've also tried copying timezones database from the MongoDB documentation, but it doesn't make any difference:
curl -O https://downloads.mongodb.org/olson_tz_db/timezonedb-latest.zip
unzip timezonedb-latest.zip
rsync -a --delete timezonedb-2021a/ /usr/share/zoneinfo/
systemctl restart mongod
What could be the problem? Why the system database doesn't fit or work together with MongoDB?
+12:00
instead ofEtc/GMT+12
? It's the same, just a different format.