How to convert an NSTimeInterval (seconds) into minutes

前端 未结 12 963
轮回少年
轮回少年 2020-11-28 01:27

I\'ve got an amount of seconds that passed from a certain event. It\'s stored in a NSTimeInterval data type.

I want to convert it into

12条回答
  •  北海茫月
    2020-11-28 01:44

    Since it's essentially a double...

    Divide by 60.0 and extract the integral part and the fractional part.

    The integral part will be the whole number of minutes.

    Multiply the fractional part by 60.0 again.

    The result will be the remaining seconds.

提交回复
热议问题