Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ilx.mac

macrumors member
Original poster
Mar 10, 2009
63
0
Hi there,

I need to get the current time in the format HH:MM:SS AM/PM. I have the date in textfield1.text. I tried using NDDate. But could not get the expected.
Can some one help me ?


Thanks in Advance!:)
 
Take a look at the NSDate method:
Code:
- (NSString *)descriptionWithCalendarFormat:(NSString *)[I]formatString[/I] timeZone:(NSTimeZone *)[I]aTimeZone[/I] locale:(id)[I]localeDictionary[/I]
and read through Converting Dates to Strings

Unfortunately it appears that method isn't available on the iPhone (at least from a quick glance at the documentation).

I think the recommended route is to use NSCalendar with NSDateComponents, or NSDateFormatter.
 
Oops, had the wrong documentation pulled up. Since that method isn't available, it looks like Kainjow's suggestion is the best way to go.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.