Posted By

chrisaiv on 08/22/10


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

adrianparr
PixelJuice
tspitzr


AS3: TimeCode Converter


 / Published in: ActionScript 3
 

  1. public static function timeCode(sec:Number):String
  2. {
  3. var h:Number = Math.floor(sec/3600);
  4. h = isNaN(h) ? 0 : h;
  5.  
  6. var m:Number = Math.floor((sec%3600)/60);
  7. m = isNaN(m) ? 0 : m;
  8.  
  9. var s:Number = Math.floor((sec%3600)%60);
  10. s = isNaN(s) ? 0 : s;
  11.  
  12. return (h == 0 ? "":(h<10 ? "0"+h.toString()+":" : h.toString()+":"))+(m<10 ? "0"+m.toString() : m.toString())+":"+(s<10 ? "0"+s.toString() : s.toString());
  13. }

Report this snippet  

You need to login to post a comment.