[Answered ]-Get timezone aware datetime

2👍

✅

Taking your example, you should use datetime and specify the tzinfo argument:

timezone.datetime(2014, 1, 1, tzinfo=timezone.UTC())

You may also be interested in Django’s make_aware function:

https://docs.djangoproject.com/en/dev/ref/utils/#django.utils.timezone.make_aware

0👍

Assuming your input is a string with no timezone information, just append a literal "Z" to your string. This indicates zero offset from UTC time.

Leave a comment