/ Published in: ActionScript 3
A quick and easy function to convert seconds into easily readable time. (90 seconds = 01:30)
Expand |
Embed | Plain Text
private function convertTime(secs:Number):String { var h:Number=Math.floor(secs/3600); var m:Number=Math.floor((secs%3600)/60); var s:Number=Math.floor((secs%3600)%60); return(h==0?"":(h<10?"0"+h.toString()+":":h.toString()+":"))+(m<10?"0"+m.toString():m.toString())+":"+(s<10?"0"+s.toString():s.toString()); }
Comments
Subscribe to comments
You need to login to post a comment.

Like this it gives you more control:
private function convertTime(secs:Number, format:String = ""):String { var toReturn:String;
Woops, that didn't work. i posted it here: http://www.snipplr.com/view/44445/convert-number-time-to-more-readable-time/ copy and update your version, then notify me and i will delete mine