formatting seconds into minutes?

Discussion in 'Programming' started by SGBoise, Dec 19, 2008.

  1. #1
    Hey Guys,

    I looked all over the internet on a solution but I can't find anything. I have a variable with a total number of seconds. For example 120 for 2 minutes.

    I want to convert the seconds so 02:00.

    Can someone help with this?
     
    SGBoise, Dec 19, 2008 IP
  2. archanapatel

    archanapatel Peon

    Messages:
    91
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I am giving you example in php language.
    $seconds= 120; (any seconds)
    $min = $seconds/60;
    $sec = $seconds%60;

    echo $min.":".$sec;

    I hope this will help you.
     
    archanapatel, Dec 19, 2008 IP
    SGBoise likes this.
  3. SGBoise

    SGBoise Peon

    Messages:
    647
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks. That's was easy. I was thinking there would be a function similar to strftime. This works great.
     
    SGBoise, Dec 19, 2008 IP