I have an NSString like this: @"3/15/2012 9:15 PM" and I would like to convert it to NSDate, I have done like this:
NSString *str =@"3/15/2012 9:15 PM";
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"mm/dd/yyyy HH:mm"];
NSDate *date = [formatter dateFromString:];
NSLog(@"%@", date); // date = null
Can you help me please, thanks.
Use the following solution
Edit:
Sorry, the format should be as follows:
And the time shown will be GMT time. So if you add/subtract the timezone, it would be 9:15 PM.
Edit: #2
Use as below. You would get exact time too.