[Answered ]-Formating Django TimeField in a Django view

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

Leave a comment