I am trying to format the string of a DateTimeField contained in one of my models.
I am using this method inside the model:
def HTMLDisplayTime(self):
time = self.time.date.strftime(%a %H:%M %d/%m/%y)
return time
Where "self.time" refers to the DateTimeField in question.
I have tried several variations, omitting some items, with and without .date preceding the .strftime method, and have imported both import datetime and from datetime import datetime.
Try using quotes around the format argument in strftime() like:
time = self.time.strftime('%a %H:%M %d/%m/%y')
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