A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: second to minute and second

  1. #1
    Member
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    84

    second to minute and second

    I have a variabel with number of second.

    exempel 3234

    Now I like to make that into 00:00

    is that any command in flash that can format that to me?
    Cazz

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    Location
    uk
    Posts
    11,222
    Code:
    var sx = 3234;
    var mins = Math.floor(sx / 60); // divide by 60 and round down to find the number of minutes
    var seconds = sx % 60; // then find the remainder for the number of seconds
    
    if (mins < 10) mins = "0" + mins; // pad with leading zeros if needed
    if (seconds < 10) seconds = "0" + seconds;
    
    trace(mins + ":" + seconds);

  3. #3
    Member
    Join Date
    Aug 2003
    Location
    Asia
    Posts
    74
    //here'is the algorithm...

    function getTime (Seconds){
    HH = Seconds div 3600;
    if(HH == 0){
    MM = Seconds div 60 ;
    if(MM == 0){
    myTime = Seconds;
    }
    else{
    SS = Seconds mod 60;
    myTime = MM + ":" + SS;
    }
    }
    else{
    myTime = HH + ":" + MM + ":" + SS;
    }
    Return myTime;
    }

    //how to use
    myTime = getTime(3234);
    //the result will be 53:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center