您非常接近,但是您需要在解析原始字符串之前指定它的日期格式,然后在创建它之前设置您希望输出采用的日期格式:
NSString *dateStr=@"29/07/2013 02:00am";
// Create a date formatter
NSDateFormatter * formatter=[[NSDateFormatter alloc] init];
// As rmaddy pointed out, you should set the locale:
[formatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]];
// Set the date format for the input string
[formatter setDateFormat:@"dd/MM/yyyy hh:mma"];
// Create the NSDate from the string
NSDate *date=[formatter dateFromString:dateStr];
// Set the date format for the output string
[formatter setDateFormat:@"hh:mma"];
// Create the output string
NSString *finalDate=[formatter stringFromDate:date];
NSLog(@"%@",finalDate); // Output is: 02:00AM