문제

I use the code:

NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        [dateFormatter setDateFormat:@"yyyy-MM-dd hh:mm:ss"];
        NSDate *eventCreationDate = [dateFormatter dateFromString:eventCreationDateString];
        NSLog(@"eventCreationDateString = %@; eventCreationDate = %@", eventCreationDateString, eventCreationDate);

NSLog result is: eventCreationDateString = 2014-01-23 14:42:27; eventCreationDate = (null)

It's really strange.

도움이 되었습니까?

해결책

Use like

[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];

Your time is in 24hr format so use HH instead of hh

다른 팁

Your format should be

yyyy-MM-dd HH:mm:ss
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top