Reputation: 13
I have a template variable:
{{article.pub_date}}
that outputs this:
May 25, 2011, 7:52 p.m.
How can I get just the date without the time:
May 25, 2011
without the:
, 7:52 p.m.
I only have access to the template tags/variables not the python code.
Upvotes: 1
Views: 103
Reputation: 7831
Also you can set a default format if you want a format used all over the site
https://docs.djangoproject.com/en/dev/ref/settings/?from=olddocs#date-format
Upvotes: 0
Reputation: 9584
{{article.pub_date|date:"F j, Y"}}
Django uses the same formatting as PHP date objects.
Upvotes: 1
Reputation: 22818
{{ article.pub_date|date:"DATE_FORMAT" }}
https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
Upvotes: 3