0

I am trying to assign the US/Eastern timezone for a command on my discord bot, but when I convert timezones it doesn't seem to change from naive.

    @command(name = "info",brief = "gets some info on a member")
    async def info(self,ctx, member: Optional[Member]):
        if not member:
            member = ctx.author
        embed = Embed(title = '',description = member.mention, inline = True,color = member.color)
        embed.set_author(name = member,icon_url= member.avatar_url)

       

        embed.add_field(name = "Joined", value = timezone("US/Eastern").localize(member.joined_at).strftime("%a, %b %d, %Y %I:%M %p))
        
        
        embed.add_field(name = "Account Created",value = timezone("US/Eastern").localize(member.created_at).strftime("%a, %b %d, %Y %I:%M %p")

        embed.set_thumbnail(url = member.avatar_url)
    
        embed.add_field(name = f"Roles[{len(member.roles)-1}]",value = ' '.join(str(r.mention) for r in member.roles[:0:-1]) if len(member.roles)>1 else "None", inline = False)

        await ctx.send(embed = embed)

The command itself works fine and there's not errors being thrown but I've tried many different solutions to change the timezone of the datetime object and it doesn't work.

DaPinaple
  • 11
  • 2
  • Does this answer your question? [Convert a python UTC datetime to a local datetime using only python standard library?](https://stackoverflow.com/questions/4563272/convert-a-python-utc-datetime-to-a-local-datetime-using-only-python-standard-lib) – Łukasz Kwieciński Mar 15 '21 at 14:28
  • no i tried that and it didn't work. – DaPinaple Mar 15 '21 at 15:00
  • so which datetime objects are you talking about? `member.joined_at` and `member.created_at`? what output do you get, what do you expect? – FObersteiner Mar 15 '21 at 15:36
  • Try switching the timezones, the bot might already be printing the correct timezone and you might not recognise it. – Ceres Mar 15 '21 at 15:44
  • I tried it and it didn't work to change the timezone. It shows that the timezone is different when I print it to my console but it doesn't show when I use strftime. – DaPinaple Mar 16 '21 at 15:30
  • your strftime directive doesn't include any time zone related info. add e.g. `%z` or `%Z`. – FObersteiner Mar 16 '21 at 16:17
  • well i don't want it to print out the timezone info I just want to print out the time the person joined in Eastern time. – DaPinaple Mar 16 '21 at 19:18

0 Answers0