2👍
Use the Python strftime()
function. https://docs.python.org/2/library/time.html#time.strftime
0👍
Below is an example of how to achieve this. It isn’t ideal, but this is what I came up with.
import datetime
now = datetime.datetime.now()
time = now.time()
t = time.strftime("%I:%M %p")
t = t.lower()
t = list(t)
if t[0] == '0':
t.pop(0)
t = ''.join(t)
print t
- [Answered ]-Python.exe crashes when I run manage.py runserver
- [Answered ]-Baffled by python __str__ method and unicode behaviour
- [Answered ]-Django.db.utils.ProgrammingError: operator does not exist: character varying = integer
- [Answered ]-Doing some processing locally before uploading
- [Answered ]-KeyError overriding django ModelAdmin.get_readonly_fields()
Source:stackexchange.com