October 21, 2024
Chicago 12, Melborne City, USA
python

Aware datetime objects output different UTC offsets in one timezone


My database is storing dates with time in UTC timezone.

PostgreSQL admin panel screenshot

I have a python program that uses ORM to query database. This ORM is configured to use Europe/London timezone. When I receive python datetime objects I expect them to be in +01:00 offset, but some dates have +00:00 (UTC) offset as can be seen below

@atomic()
async def test():
    async for user in User.all().order_by("-id").limit(3):
        print(user.datetime)
        print(user.datetime.timetz().tzname())

Program output

What should I do about it? How can I fix this?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video