Reputation: 1573
From this answer
In my template i need to make 1255992517000
to an date-time. i tried {{note.created|date:"U"}}
and 1255992517000|date:"U"
but it didn't work. How to get it to work? From django docs one can see it should work, but how?
Upvotes: 0
Views: 2301
Reputation: 35599
You are misunderstanding what the {{ value|date }}
filter is capable of doing. It will not turn an integer into a date object, you must be passing it an existing date object.
You could write your own template filter to convert the value into a date first.
Upvotes: 3
Reputation: 15082
Applying the filter date:"U"
is telling the template to display seconds since the Unix Epoch (January 1 1970 00:00:00 UTC).
If you want to display a readable date / time, try something like:
{{ note.created|date:"D d M Y" }}
Upvotes: 1