Best way to convert number of minutes to hh:mm AM/PM?

andydtaylor at gmail.com andydtaylor at gmail.com
Sat Mar 2 01:12:16 CET 2013


Hi,

I need to create a list of equally spaced times (as in hh:mm AM/PM) within a day to loop through. Having selected 30 minute intervals I figured I could:

* Create a list from 1 to 48
* Multiply each value by 30
* Convert minutes to a time. datetime.timedelta seems to do this, but it's not a full timestamp which means strftime can't format me a time with am/pm.

can anyone suggest a good approach to use? Ultimately I'd like to generate an equivalent to this text/format:'2:30 pm'

Thanks,


Andy



More information about the Python-list mailing list