tags:

views:

44

answers:

2

NSString *abc = @"2009-12-12 16:25:00";

i have 1 string in this format as shown above.

NSDate *currentDate = [NSDate date]; now i want currentDate in also this format as specified 2009-12-12 16:25:00

and also i want to convert this currentDate from NSdate to NSString format with specified thisformat 2009-12-12 16:25:00

help me

A: 

Use NSDateFormatter.

Ole Begemann
A: 
 NSDateFormatter* dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
 [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
 NSString* golly = [dateFormatter stringFromDate:[NSDate date]];
Jane Sales