Search code examples
python-3.xtimezonediscorddiscord.pypytz

Using pytz TImezones for discord.py


How can i get the guild.created_at time in the Europe/Berlin timezone? i tried guild.created_at.astimezone(timezone('Europe/Berlin')) and its doesnt work. i also tried other forums, tutorials and the docs, but with no success.

I've already looked at the options:

pytz localize vs datetime replace

http://pytz.sourceforge.net/

pytz - Converting UTC and timezone to local time


Solution

  • You can make use of the fromutc function:

    pytz.timezone('Europe/Berlin').fromutc(guild.created_at)