나는 다음과 같은 문자열이 있습니다변환 문자열
-(NSDate*)dateFromString:(NSString*)dateString format:(NSString*)format {
NSDateFormatter* dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"MM/dd/yy, HH:mm:ss"];
[dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
NSLog(@"%@", [dateFormatter dateFromString:strToConvert]);
}
:이 방법에 전달하고
2016년 1월 27일 11시 0분 0초
그리고
이며 nil
을 반환합니다. 내가 여기서 뭘 잘못하고 있는지 잘 모르겠다.
편집 : 이것은 iPhone에서만 일어나는 것처럼 보입니다. iPad에서는 잘 작동합니다.
무엇이'strToConvert'입니까? 메서드에 해당 변수에 대한 정의가 없습니다. –
실제로 날짜 문자열과 일치하는 날짜 형식 지정자가 필요합니다. – rmaddy
어떻게 한 장치에서만 작동하고 다른 장치에서는 작동하지 않습니까? 가능한 유일한 방법은 실제 문자열이 두 장치에서 다릅니다. 그것을 확인하십시오. – rmaddy