Saturday, January 29, 2011

Re: How to format a datetime in a webpage?

Thank you very much! I misunderstood the meaning of "date" and "the time of day"...

On Fri, Jan 28, 2011 at 8:53 PM, Jirka Vejrazka <jirka.vejrazka@gmail.com> wrote:
>         <td bgcolor="#FFFFFF" >{{record.ComplaintTime|time:"Y-m-d
> H:i"}}</td>

From the documentation:

"The time filter will only accept parameters in the format string that
relate to the time of day, not the date (for obvious reasons). If you
need to format a date, use the date filter."

 So, you need to use:
       <td bgcolor="#FFFFFF" >{{record.ComplaintTime|date:"Y-m-d H:i"}}</td>

 instead of:
       <td bgcolor="#FFFFFF" >{{record.ComplaintTime|time:"Y-m-d H:i"}}</td>

 Cheers

   Jirka

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment