I added this code
NSString *dateString=@"March 29, 2012 12:45 PM";
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
[formatter setDateFormat:@"MMMM dd, yyyy h:mm aaa"];
NSDate *date = [formatter dateFromString:dateString];
But i am receiving the following output:
2012-03-29 07:15:00 +0000
How can i get the actual format?
The reason that the time is displaying incorrectly is because when you log the NSDate it will show it to you in your local time zone.
If you want to set your date formatter to a specific time zone you can use the
setTimeZone:method. I noticed that your profile says you are located in India, and if I recall correctly, India utilizes half hour time zones that would account for the 7:15 time that it is reporting instead of 12:45.