如何将NSTimeInterval(秒)转换为分钟
问题描述:
我从某个事件中获得了一定数量的秒数。它存储在NSTimeInterval数据类型中。
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.
例如我有:326.4秒,我想将其转换为以下字符串:
5:26。
For example I have: "326.4" seconds and I want to convert it into the following string: "5:26".
实现目标的最佳方法是什么这个目标?
What is the best way to achieve this goal?
谢谢。
答
伪代码:
minutes = floor(326.4/60)
seconds = round(326.4 - minutes * 60)