How to remove T from time format %Y-%m-%dT%H:%M:%S
in python?
Am using it in my html as
<b>Start:{{ start.date_start }}<br/>
Manually format the datetime, don't rely on the default str()
formatting. You can use datetime.datetime.isoformat()
for example, passing in a space as the separator:
<b>Start:{{ start.date_start.isoformat(' ') }}<br/>
or you can use datetime.datetime.strftime()
to control formatting more finely:
<b>Start:{{ start.date_start.strftime('%Y-%m-%d %H:%M:%S') }}<br/>
@register.filter
def isotime(datestring):
datestring = str(datestring)
return datestring.replace("T"," ")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.