I want to print some sort of time stamp or some sort of function to tell what day and time it is in a template. In my views I have
time = datetime.now()
and in my template I have
{{time}}
All this does is prints out a <type 'datetime.date'>
object.
if its just in the template, use now
It is {% now "f" %}
Normally, this should work:
from datetime import datetime
def a_view(request):
return render_to_response("a_template.html", {
'time':datetime.now(),
}, context_instance=RequestContext(request))
Then render the datetime object in your template:
<p>{{time}}</p>
Use the built-in date filter as described here to format your date if you like.
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