Home > Enterprise >  How to make a shortcut of day display e.g Thursday 14/07/2022 => Thu 14/07/2022 in Django html te
How to make a shortcut of day display e.g Thursday 14/07/2022 => Thu 14/07/2022 in Django html te

Time:07-15

I have booking start date as follow <p>{{ booking.start_time|date:"j/F/Y" }}</p> on Django html template which it displays the date as 14/July/2022 on the DOM, how I can make it display like this Thu 14/07/2022

CodePudding user response:

You can do it like that:

from django.shortcuts import render
import datetime
currentdate = datetime.date.today()
print(currentdate)
print(currentdate.strftime("%a %d/%m/%y"))

In django html template i think it would be like that. I choose "d" for the day because it will be displayed with leading zeros.

<p>{{ booking.start_time|date:"D d/m/Y" }}</p>

CodePudding user response:

According to the documentation:

 <p>{{ booking.start_time|date:"D j/m/Y" }}</p>
  • Related