将 pytz 时区用于 discord.py
Using pytz TImezones for discord.py
如何获取 Europe/Berlin
时区的 guild.created_at
时间?
我试过 guild.created_at.astimezone(timezone('Europe/Berlin'))
但它不起作用。我也尝试了其他论坛、教程和文档,但没有成功。
我已经看过选项了:
pytz localize vs datetime replace
pytz - Converting UTC and timezone to local time
您可以使用 fromutc 函数:
pytz.timezone('Europe/Berlin').fromutc(guild.created_at)
如何获取 Europe/Berlin
时区的 guild.created_at
时间?
我试过 guild.created_at.astimezone(timezone('Europe/Berlin'))
但它不起作用。我也尝试了其他论坛、教程和文档,但没有成功。
我已经看过选项了:
pytz localize vs datetime replace
pytz - Converting UTC and timezone to local time
您可以使用 fromutc 函数:
pytz.timezone('Europe/Berlin').fromutc(guild.created_at)