/ Published in: ActionScript 3
based on: http://www.snipplr.com/view/33913/actionscript-seconds-to-standard-time-format/
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
private function convertTime(secs:Number, format:String = ""):String { var toReturn:String; var h:Number=Math.floor(secs/3600); var m:Number=Math.floor((secs%3600)/60); var s:Number=Math.floor((secs%3600)%60); if (format) { if(format == "h") { toReturn = (h==0?"":(h<10?"0"+h.toString()+":":h.toString())); } else if(format == "m") { toReturn = ((m<10?"0"+m.toString():m.toString())); } else if(format == "s") { toReturn = ((s<10?"0"+s.toString():s.toString())); } } else { toReturn = (h==0?"":(h<10?"0"+h.toString()+":":h.toString()+":"))+(m<10?"0"+m.toString():m.toString())+":"+(s<10?"0"+s.toString():s.toString()); } return toReturn; }