Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django template date filter format string question

Tags:

python

django

I have a datetime value that is available in a django template.

I am trying to format the date as "d-mmm"

so for example dates are formated as:

  • 5-Mar
  • 10-Mar
  • 4-Apr

etc.

I have tried different combinations - NOTHING works so far?. I hope I dont have to write a custom filter just to format a date ?

[Edit]

I tried the 'obvious' format string like: 'j-M', 'j-N', (even 'j-mmm' and 'd-mmm')

like image 387
skyeagle Avatar asked Dec 10 '22 13:12

skyeagle


1 Answers

Have you tried {{ some_date|date:"j-M" }}?

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#date

like image 76
Benjamin Wohlwend Avatar answered Dec 26 '22 07:12

Benjamin Wohlwend