I tried to get a NSDate from a NSString with UNKNOWN format, So I wrote a function like below
-(void)dateFromString:(NSString*)string {
NSE
You have to use NSDateFormatter. Try replace your if statement with:
if ([match resultType] == NSTextCheckingTypeDate) {
NSDate *dateAfter = [match date];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd 'at' HH:mm"];
NSString *formattedDateString = [dateFormatter stringFromDate:dateAfter];
NSLog(@"After: %@", formattedDateString);
}
If you want to display it in different format you have to change this line to required format:
[dateFormatter setDateFormat:@"yyyy-MM-dd 'at' HH:mm"];
If you want it to match your first example change it to:
[dateFormatter setDateFormat:@"EEEE, MMMM dd, yyyy 'at' HH:mm:ss a zzzz"];