[Django]-Django โ€“ present current date and time in template

95๐Ÿ‘

โœ…

Try using built-in django template tags and filters:
https://docs.djangoproject.com/en/stable/ref/templates/builtins/#now

Examples:

It is {% now "jS F Y H:i" %}
It is {% now "SHORT_DATETIME_FORMAT" %}
๐Ÿ‘คSara

0๐Ÿ‘

The full list of datetime formats can be found in the docs. Using the format options there, you can construct the current datetime in whatever format you want. For example,

It is {% now "l, F j, Y g:i A" %}.

displays

It is Wednesday, September 27, 2023 11:58 PM.

on the webpage, and

It is {% now "" %}.

It is {% now "N j, Y" %}.

both display

It is Sept. 28, 2023.
๐Ÿ‘คcottontail

Leave a comment