0

I am trying to get a DateTimeField element to render appropriately.

Updating the timezone field in my settings.py file allowed me to display the correct time, I did so by simply modifying one field in said file:

TIME_ZONE = 'Europe/Berlin'

But I am using this method in order to format it:

def displayTime(self):
        return self.added.strftime('%a %H:%M:%S  %d/%m/%y')

The problem is that when I use this method, the time is off by an hour again, as if I never edited the timezone field inside settings.py.

In other words, when I access the time from a template variable modelObject.time -- the accurate time is displayed, but when I access the time using the method with the strftime method, modelObject.displayTime the time is off by an hour.

user8951490
  • 833
  • 1
  • 10
  • 21
  • https://stackoverflow.com/a/11909289/2282638 – Sandeep Balagopal Dec 06 '17 at 13:21
  • Possible duplicate of [Using strftime on a django datetime produces a UTC time in the string](https://stackoverflow.com/questions/11909071/using-strftime-on-a-django-datetime-produces-a-utc-time-in-the-string) – solarissmoke Dec 07 '17 at 03:14

0 Answers0