有人能告訴我我的時間格式化器有什麼問題嗎?當我使用iPod 6.0的時間格式化工程。但是當我使用iphone 5 6.1時,formatter返回nil。NSDateFormatter在iphone 5中返回nil ios 6.1
這裏是我關於timeFormatter的代碼。
NSDateFormatter *tempFormatter = [[[NSDateFormatter alloc]init] autorelease];
[tempFormatter setDateFormat:@"yyyy-MM-dd hh:mm"];
NSString *dateandtime = @"2013-05-27 19:00";
//set end date and time
NSDateFormatter *tempFormatterTo = [[[NSDateFormatter alloc]init] autorelease];
[tempFormatterTo setDateFormat:@"yyyy-MM-dd hh:mm"];
NSString *dateandtimeTo = @"2013-05-27 20:00";
NSDate *startDate = [tempFormatter dateFromString:dateandtime];
NSDate *endDate = [tempFormatterTo dateFromString:dateandtimeTo];
在此先感謝。請幫幫我。
它應該像「yyyy-MM-dd HH:mm」 –
謝謝!!有用! – Edgar