Good day, I'm trying to convert NSString that I'm getting from the server to NSDate object. That is the code:
NSString *date = @"Sep 12 at 12:03 am";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MMM d 'at' H:m a"];
self.messageDateAndTime = [dateFormatter dateFromString:date];
NSLog(@"NSDate: %@", self.messageDateAndTime);
I'm getting date in the format that date string has. After I'm trying to create my own formatter for this date format. But anyway, I'm getting null!
What I'm doing wrong?
[[NSDateFormatter alloc] init]is an expensive operation. Better to cache the result. - Berik