簡體   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