views:

237

answers:

1

I know the quick and dirty way of dividing by 60 to get minute, hours, etc

But is there an official way in the API already implemented, and using the appropriate language for minutes, seconds, etc?

Thanks for any help.

+4  A: 

Use one of NSDate's -dateWithTimeInterval... methods to create a date from your interval, then hand it to an NSDateFormatter that is configured to display the date formatted as desired.

Joshua Nozzi
do you know if it is able to do __ hours __ minutes? I am unfamiliar with this class, but what I looked at didn't seem to be able to print out the local word for hour or minute.
Alex Gosselin
Sorry, think you'll have to localize the full hours/minutes spelling...
Kendall Helmstetter Gelner
You can use NSDateComponents to get at the number of hours, etc. As for the date format itself, -setDateFormat: is used to set the specific format. As stated in the docs, NSDateFormatter is based on ICU standards, so use ICU date formatting standards to specify the format. I don't know if this includes localized unit words like "hours", though. That part is yours to google.
Joshua Nozzi