Reputation: 1799
I used following commands to change timezone
in my Ubuntu 16.04 server
sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
and tzselect
After typing date
I get the correct datetime.
But on mongodb when I print time of recently added document by res.ops[0]._id.getTimestamp()
I still get the datetime prior to the timezone change.
I restarted mongodb and the server itself. But still no change. And I am using node.js as backend.
Upvotes: 0
Views: 325
Reputation: 252
You need to save the time as UTC and then on the server side get the document with time and apply to it your wanted timezone. That way you decouple timezones from your data.
Upvotes: 1