PHP convert specific string to well formated time string -


we have lot of strings storing time took participants finish track. there 2 different types of strings ( <1 hour , >1hour ):

54:37 01:12:20 

what reasonable way format these strings in php before displaying keep same standard - hh:mm:ss (the first string needs 00:54:37 )?

any or guindace appreciated.

simple way

$time = str_pad($time,8,'00:',str_pad_left)

what does: fill string 00: left full lenght of 8

or $time = strlen($time)==8?$time:"00:$time"

what does: check if string 8 chars nothing else add 00:

this solutions if 2 different types given.

this wont work: print date('h:i:s',strtotime('54:37'))


Comments