Format time as hh:mm:ss with leading zeros if needed

Taken from http://stackoverflow.com/a/12612778
Merge pull request #1 from hugovk/patch-1

Format time as hh:mm:ss with leading zeros if needed