I’m working on a django template, and I want to format a date with the following format ‘YYDDD’ (sometimes known as julian date format) where:
- YY is the last 2 digits of the year
- DDD is the day of the year with 3 digit format
I tried to achive this with the date filter:
{{ value|date:"yz" }}
but “z” doesn’t keep the output with 3 digits, it uses the minimum possible amount. If the day number is 3 (3rd January) it will print 3 istead 003.
For example, for the date 7th February of 2012 i would expect 12038 but instead I get 1238 (no zero padding).
How can I get this right?
You can write your django custom filter or use jcroft’s snippet: