A slight OCD question here - I'm using the {% humanize %} tag in Django which gives me date times returned in the following format:
June 17, 2017 07:24 pm
Now, within my post model in Django I am returning the following:
def published_date(self):
"""Returns a humanized date format for Algolia indexing."""
humanized_published_date = str(self.publish.strftime("%B %d, %Y %I:%M%p"))
return humanized_published_date
All works well. HOWEVER, the format returned in the above method is:
June 17, 2017 07:24PM
I've had a previous read of the datetime documentation here (https://docs.python.org/2/library/datetime.html) specifically the section "8.1.7. strftime()
and strptime()
Behavior". I can see what I may need is the de_DE formatting - which displays a 12 hour clock suffix as pm and not PM.
So, my question is this. How do I re-format date times to give a format as the following: June 17, 2017 07:24 pm
.* (As mentioned in the above code - I'm currently using %B %d, %Y %I:%M%p
).
*N.B. I'm OCD to the point where I don't want June 17, 2017 07:24PM or even June 17, 2017 07:24pm! i.e., I need that space between the twelve hour clock and the ante meridiem and post meridiem suffixes.