php - Padding a time on the left with sprintf? -
I am trying to use sprintf () in PHP at one time (Time of an MP3 time) .
Sprint ("% 02d: 2d: 2d", $ time);
The function that gives time, for example, '1:56' if the MP3 is 1 minute 56 seconds long, and it returns the call "01:56:00" while It should be 00:01:56) How can I take it to work? How can I tell a sprint to the pad on the left?
Or is there a better way to go about this? Can be a more reasonable job?
Thanks
I think you should calculate each element individually , Then about:
sprintf ("% 02d:% 02d:% 02d", bottom ($ time / 3600), floor ($ time / 60)% 60, $ time 60 %);
Comments
Post a Comment