“June 8, 2023, 02:00 pm” change to “8 June 2023, 14:00”

huangapple go评论68阅读模式
英文:

"June 8 2023, 02:00 pm" change to "8 June 2023, 14:00"

问题

请帮我解决这个问题。我在Windows操作系统上创建了一个Django项目,然后将其转移到Debian服务器上,一切都正常,但日期显示有问题:我使用updated_at = models.DateTimeField(auto_now=True),在Windows操作系统上显示为:2023年6月8日,14:00,但在Debian上却以某种原因显示为:2023年6月8日,下午02:00。可能的问题是什么?如何修复?

英文:

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?

答案1

得分: 0

需要在{{ updated_at }}之前添加|date:"j F Y, G:i",之后应如下所示:{{ updated_at|date:"j E Y, G:i" }}。您可以在这个链接中找到有关Django模板中日期过滤器的更多信息:https://docs.djangoproject.com/en/4.0/ref/templates/builtins/#date

英文:

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

huangapple
  • 本文由 发表于 2023年6月8日 19:07:26
  • 转载请务必保留本文链接:https://go.coder-hub.com/76431199.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定