Ilya Suzdalnitski Ilya Suzdalnitski - 1 year ago 109
Objective-C Question

How to convert an NSTimeInterval (seconds) into minutes

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 minutes and seconds.

For example I have: "326.4" seconds and I want to convert it into the following string:

What is the best way to achieve this goal?


Answer Source


minutes = floor(326.4/60)
seconds = round(326.4 - minutes * 60)