Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
時間を秒単位で保存していますが、「2m 6s」のように分と秒で表示したいと思います。理想的には、これはローカリゼーションで行われます。どうすればこれを達成できますか?
これは本当に標準的な数学に要約されます。
秒がある場合は、60 で割るだけで分数が得られます。残りの秒数は、総秒数のモジュラスを 60 で割るだけです。
例えば
int minutes = seconds / 60; int seconds = seconds % 60; NSString *formattedTime = [NSString stringWithFormat:@"%im %is", minutes, seconds];
それは実際には非常に簡単です!