I am getting date null and I dont know why, Can someone please help
Input date: @”June 14, 2012 – 00:00:00 UTC”
Expected output: @”June 14, 2012″
NSString *rawDate = @"June 14, 2012 - 00:00:00 UTC";
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"UTC"]];
[dateFormatter setDateFormat:@"MMMM dd, yyyy - HH:mm:ss"];
NSDate *date = [dateFormatter dateFromString:rawDate];
NSLog(@"Check the string date: %@", date);
Try this out:
You need to add a format identifier for the timezone portion of the input string.