0

I am looking for a function from the django.utils.library that would take a datetime from a specified timezone and return its UTC equivalent. Does such a function exist?

Extranomical
  • 385
  • 1
  • 3
  • 13

1 Answers1

1

To convert a datetime object that already has timezone information to another timezone (UTC in this case) you can use django.utils.timezone.localtime

from django.utils.timezone import localtime, utc
datetime_object_as_utc = localtime(datetime_object, timezone=utc)
Iain Shelvington
  • 31,030
  • 3
  • 31
  • 50