etrader Posted January 29, 2011 Share Posted January 29, 2011 I used the following code to convert the length in seconds to min:second format $sec=$duration % 60; if ($sec=="0"){ $min=$duration/60; $duration=''.$min.':00'; }else{ $min=(($duration-$sec)/60); $duration=''.$min.':'.$sec.''; } everything is OK, but it shows 35:5 instead of 35:05. I mean it disregards the first 0 when the second is 1-digit. :-\ Quote Link to comment Share on other sites More sharing options...
dragon_sa Posted January 29, 2011 Share Posted January 29, 2011 $sec=$duration % 60; if ($sec=="0"){ $min=$duration/60; $duration=''.$min.':00'; }else{ $min=(($duration-$sec)/60); if (strlen($sec)=='1') $sec="0".$sec; $duration=''.$min.':'.$sec.''; } Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.