I have a datetime field 'scantime' in my django model.
scandate = models.DateTimeField(max_length=100)
When I retrieve this from mysql database, it is displaying in my django UI like this: Oct. 16, 2014, 4:37 p.m.
But when I debug, this value is something like this: datetime.datetime(2014, 10, 13, 6, 8, 47, tzinfo = UTC).
Though seconds are stored in DB, django is not displaying seconds in the UI bydefault.
My template code is like this:
{% for key,value in logdata.items %}
<tr>
{% for item in value %}
<td>{{ item }}</td>
{% endfor %}
</tr>
{% endfor %}
Is there any way that I can display seconds in UI? Please help me
Try like this,
<td>{{ item|date:'Y-m-d H:i:s' }}</td>
Django documentation: https://docs.djangoproject.com/en/dev/ref/templates/builtins/#date
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With