Get local timezone in django

后端 未结 9 644
轻奢々
轻奢々 2020-12-04 17:47

I have a mysql DATETIME value that is stored in system time, UTC. I need to convert that to my local timezone in django. Here is what I currently have:

9条回答
  •  生来不讨喜
    2020-12-04 18:32

    It took me a while to find this, but this is how I solved it. I guess the user's timezone from IP address and then do this in Django 2 and beyond:

    {% load tz %}
    {% timezone "Europe/Paris" %}
        Paris time: {{ object.date }}
    {% endtimezone %}
    

提交回复
热议问题