On Mar 3, 12:54 am, Scott Macri <scottma...@gmail.com> wrote:
> OK, I guess a better question is how do I switch my time outputs using
> datetime.time from 24-hour clock to 12-hour clock so I can use am/pm?
>

I think this will work for what you need:

>>> import datetime
>>> TIME_CHOICES = [(datetime.time(12, min), datetime.time(12, 
>>> min).strftime('%I:%M %p')) for min in range(0, 60, 15)]
>>> print tuple(TIME_CHOICES)
((datetime.time(12, 0), '12:00 PM'), (datetime.time(12, 15), '12:15
PM'), (datetime.time(12, 30), '12:30 PM'), (datetime.time(12, 45),
'12:45 PM'))

You'll have to add another loop for the hours if you want more than
just 12:xx.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to