I have a date data that saved in my postgresql it looks like this
I'm getting the date using this django models:
ddate = list(MyModel.objects.values('created_at'))
getDates = [d['created_at'] for d in ddate if 'created_at' in d]
print(getDates)
the print output will look like this which is, if I compared the time zone from postgres and time zone from my python they are not accurate. How can I fix this?
my model.py looks like this:
class MyModel(models.Model):
created_at = models.DateTimeField(auto_now=True)
class Meta:
db_table = "tablename"
I tried using the this but, I'm having an error because my data is a list of dates it's says that "'list' object has no attribute 'replace'"
utctime = getDates //list of dates//
from_zone = tz.gettz("UTC")
to_zone = tz.gettz("mytimezone")
utctime = utctime.replace(tzinfo=from_zone)
new_time = utctime.astimezone(to_zone)
print(utctime)