I ilx.mac macrumors member Original poster Mar 10, 2009 63 0 Jul 23, 2009 #1 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!
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!
G Guiyon macrumors 6502a Mar 19, 2008 771 4 Cambridge, MA Jul 23, 2009 #2 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
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
K kainjow Moderator emeritus Jun 15, 2000 7,958 7 Jul 23, 2009 #3 Guiyon said: 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 Click to expand... 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.
Guiyon said: 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 Click to expand... 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.
G Guiyon macrumors 6502a Mar 19, 2008 771 4 Cambridge, MA Jul 23, 2009 #4 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.
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.