Tôi có một NSString
như thế này: @"3/15/2012 9:15 PM"
và tôi muốn chuyển nó sang NSDate
, tôi đã làm như thế này:tạo NSDate từ một chuỗi
NSString *str [email protected]"3/15/2012 9:15 PM";
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
[formatter setDateFormat:@"mm/dd/yyyy HH:mm"];
NSDate *date = [formatter dateFromString:];
NSLog(@"%@", date); // date = null
bạn có thể giúp tôi xin vui lòng, cảm ơn.
thể trùng lặp của [chuyển đổi chuỗi để nsdate] (http://stackoverflow.com/questions/2311421/convert-string- to-nsdate) –