Posted By

visualadvance on 03/12/11


Tagged


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

burnandbass
scottwatkins
fedecp


AS3: Format Time


 / Published in: ActionScript 3
 

Easily convert seconds into a hh:mm:ss format.

  1. private function formatTime (input:int):String
  2. {
  3. var hrs:String = (input > 3600 ? Math.floor(input / 3600) + ':' : '');
  4. var mins:String = (hrs && input % 3600 < 600 ? '0' : '') + Math.floor(input % 3600 / 60) + ':';
  5. var secs:String = (input % 60 < 10 ? '0' : '') + input % 60;
  6. return hrs + mins + secs;
  7. }

Report this snippet  

You need to login to post a comment.