Tag Archive > formatting

MansoTrick: Convert 24h time string to 12h AM/PM format (Python)

Manso trick to convert from 24h time format to 12h (AM/PM) time format in Python def ampmformat (hhmmss): “”” This method converts time in 24h format to 12h format Example: “00:32” is “12:32 AM” “13:33” is “01:33 PM” “”” ampm = hhmmss.split (“:”) if (len(ampm) == 0) or (len(ampm) > 3): return hhmmss # is […]

Continue reading

, ,

Manso Trick: Pad a number with leading zeroes in javascript

I was missing a simple and elegant method for padding a number with leading zeroes in javascript. A typical example of leading zeroes is when you want to show the current time and you want the time to be formatted like hh:mm. There is no problem when it’s 12:40, but when is five minutes past […]

Continue reading

, , ,