Saturday, 27 July 2013

NSDate from NSString. Fetch Date from string.

+(NSDate*)dateFromString:(NSString*)dateStr
{
    // Choose your format according to date string
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"LLLL d,YYYY"];
    NSDate *date = [dateFormat dateFromString:dateStr];
    NSLog(@"String:%@ convert to date:%@",dateStr, date.description);

    return date;
    
}

No comments:

Post a Comment