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. :-\ Link to comment https://forums.phpfreaks.com/topic/226033-displaying-time-format/ 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.''; } Link to comment https://forums.phpfreaks.com/topic/226033-displaying-time-format/#findComment-1166889 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.