Can't change timezone python

Question:
I’m using this code to change the timezone. But when my repl run, the discord bot and the wsgi server log doesn’t change its time.

# Aplly runtime patches to synchoronous functions in standart Python library
# make it "gevent-friendly"
from gevent import monkey
monkey.patch_all()

# correct timezone
import os
import time
os.environ["TZ"] = "Asia/Ho_Chi_Minh"
time.tzset()

# ... run wsgi server and discord bot

Hello, @kienne.

It seems to me that the thing is that you change the time zone through the os module. This module is needed to install the interaction of the code and the operating system. It changes the time zone of the user’s device, not the bot discord.

To change the time zone of the discord bot, try using another module.

Can you give a link to your repl with discord bot?

3 Likes

Sorry for my late reply.
I want to change those logs. The discord.py and gevent.pywsgi WSGIServer both log with UTC timezone. I want to change them to UTC+7 timezone instead.

My repl.
https://replit.com/@kienne/99#main.py

I followed your link and saw this:

1 Like

sorry. I forget to make the repl public. Already changed it.