Convert "minutes since midnight" to time (convert to NSDate?)

Posted by Canada Dev on Stack Overflow See other posts from Stack Overflow or by Canada Dev
Published on 2010-03-20T12:08:43Z Indexed on 2010/03/20 12:11 UTC
Read the original article Hit count: 115

Filed under:
|

I am getting some open/closed times as integers since midnight. For example:

"1140" = 19:00 (or 7 pm if you will) or; "570" = 9:30 (or 9.30 am)

I can easily get the time in European format, just by doing doing a simple calculation and formatting:

[NSString stringWithFormat:@"%d:00", (T / 60)]

However, this doesn't work for half hours, such as "570 minutes since midnight". Also, I run into problems if I want to include a bit of localization, because some people may prefer AM/PM times.

Does NSDate include a method for easily implementing times using the above? Or can anyone tell me how I would at least convert a time like "570 minutes since midnight" to 9:30 properly. Right now it obviously won't write the :30 part.

Thank you

© Stack Overflow or respective owner

Related posts about iphone

Related posts about nsdate