繁体   English   中英

iOS6 TimeInterval错误

[英]iOS6 TimeInterval bug

我有一些代码可以在iOS 5中完美运行,但在iOS 6中却无法正常工作。

这是TimeIntervalSinceDate方法...

我发现其他人有此问题,但没有解决方案:

这是我的代码:

  NSString *origDate = @"2012-11-29 19:43:30";

   NSDateFormatter *df = [[NSDateFormatter alloc] init];
    [df setFormatterBehavior:NSDateFormatterBehavior10_4];
    [df setDateFormat:@"YYYY-MM-dd HH:mm:ss"];
    NSDate *convertedDate = [df dateFromString:origDate];
    [df release];


    NSDate* sourceDate = [NSDate date];

    NSLog(@"sourceDate: %@", sourceDate);
    NSLog(@"convertedDate: %@", convertedDate);

    NSTimeInterval ti = [ sourceDate timeIntervalSinceDate:convertedDate];

    NSLog(@"interval double: %f", ti);

在iOS 5中,我将其作为值:

interval double: 711.113610

在iOS 6中,我得到:

interval double: 31623151.242078

有什么建议么?

谢谢

看看苹果公司对日期格式化程序怎么说:

一个常见的错误是使用YYYY。 yyyy指定日历年,而YYYY指定在ISO年周日历中使用的年份(“年中的一周”)。 在大多数情况下,yyyy和YYYY产生相同的数字,但是它们可能不同。 通常,您应该使用日历年。

iOS在5.1和6之间切换了Unicode版本。

iOS 6.0-使用tr35-25代替tr35-19

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM