NSTimeInterval Formatting

Baub picture Baub · Nov 14, 2011 · Viewed 21.6k times · Source

I want to take my NSTimeInterval and format it into a string as 00:00:00 (hours, minutes, seconds). What is the best way to do this?

Answer

Johan Kool picture Johan Kool · Nov 10, 2014

Since iOS 8.0 there is now NSDateComponentsFormatter which has a stringFromTimeInterval: method.

[[NSDateComponentsFormatter new] stringFromTimeInterval:timeInterval];