skip to Main Content

please help me figure this out. I made a project on django on Windows OS, transferred it to debian server, everything works, but there is a problem with displaying the date: I use updated_at = models.DateTimeField(auto_now=True), on Windows OS it is displayed as: 8 June 2023, 14:00, but on debian for some reason it is displayed as: June 8 2023, 02:00 pm. What could be the problem? How to fix?

2

Answers


  1. Chosen as BEST ANSWER

    Need to add |date:"j F Y, G:i"

    before: {{ updated_at }}

    after: {{ updated_at|date:"j E Y, G:i" }}

    https://docs.djangoproject.com/en/4.0/ref/templates/builtins/#date


  2. To change the date format from "June 8 2023, 02:00 pm" to "8 June 2023, 14:00" in Django, you can use the following template code:

    {{ object.updated_at|date:"j F Y, H:i" }}

    Make sure to replace object.updated_at with the actual DateTimeField you want to display.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search