[Solved] How can i convert string to date with some strange format


You can use this function to get date from your string.

 - (NSDate *) dateFromServerAttributeDateFormat:(NSString *)dateString
    {
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ss.SSS"];
        [dateFormatter setLocale:[NSLocale currentLocale]];
        if (!dateString.length){
          return nil;
          }
        else
            return [dateFormatter dateFromString:dateString];

    }

in swift

   func dateFromServerString(dateString:String) -> NSDate {
    let dateFormater = NSDateFormatter()
    dateFormater.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSS"
    dateFormater.locale = NSLocale.currentLocale()
    return dateFormater.dateFromString(dateString)!
}

2

solved How can i convert string to date with some strange format