I hope this helps . This answer describes all the format specifiers in detail. hh stands for "hour (1-12, zero padded)" - so you can't write 15h here. If you wish to use a 24-hour time format, use HH instead.
I wish this helpful for you If you're working with fixed-format dates, you should first set the locale of the date formatter to something appropriate for your fixed format. In most cases the best locale to choose is en_US_POSIX, a locale that's specifically designed to yield US English results regardless of both user and system preferences. en_US_POSIX is also invariant in time (if the US, at some point in the future, changes the way it formats dates, en_US will change to reflect the new behavior, but en_US_POSIX will not), and between platforms (en_US_POSIX works the same on iPhone OS as it does on OS X, and as it does on other platforms).
// String to Date
NSString *birthday = @"Jun 29, 2013, 8:45 AM";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMM dd, yyyy, HH:mm a"];
dateFormatter.timeZone = [NSTimeZone timeZoneForSecondsFromGMT:0];
// Setting the locale to POSIX ensures that
// the user's locale won't be used
dateFormatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"];
NSDate *birthdayDate = [dateFormatter dateFromString:birthday];
// Date to String
[dateFormatter setLocale:[NSLocale currentLocale]];
dateFormatter.timeZone = [NSTimeZone systemTimeZone];
NSString *originalBirthday = [dateFormatter stringFromDate:birthdayDate];
NSDateFormatter- dateFromString returning nil when set AM/PM
By : Mohammad Masoumi
Date : March 29 2020, 07:55 AM
I wish this helpful for you I have the following string 2016-10-26T16:01:18.361Z and works with the folowing code: , As @rmaddy said this code works fine.