使用NSDATE在模拟器上工作,但在设备中不使用NSDATE进行计算



我正在使用以下代码来计算剩余的时间,该代码在模拟器上良好工作,但在iPad设备上的白天小时和秒都提供了所有零值

`NSTimeInterval remainingSec = [databaseDate timeIntervalSinceNow];
    if (!timer || remainingSec <= 0) {
        [timer invalidate];
        timer = nil;
        // getting time from database

NSLocale *indianEnglishLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_IN"];
    NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"Asia/Kolkata"];
    NSDateFormatter *dateFrmattr = [[NSDateFormatter alloc] init];
    [dateFrmattr setLocale:indianEnglishLocale];
    [dateFrmattr setDateFormat:@"V"];
    [dateFrmattr setTimeZone:timeZone];
    dateFrmattr.timeStyle = NSDateFormatterNoStyle;
    dateFrmattr.dateFormat = @"MM/dd/yyyy HH:mm:ss zzz";
    NSDate *finalDate = [dateFrmattr dateFromString:@"11/01/2012 10:00:00 IST"];
   // NSDate *startDate = [[NSDate alloc] init];
    self.databaseDate = [[NSDate alloc] init];;
    remainingSec = [finalDate timeIntervalSinceDate:databaseDate];
    timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self 
                                           selector:@selector(showClock)  
                                           userInfo:nil 
                                            repeats:YES];
}
//NSInteger remainder = ((NSInteger)remainingSec)% 3600;
NSInteger days = remainingSec/86400;
NSInteger int1 = ((NSInteger)remainingSec) % 86400;
NSInteger hours = int1/3600;
NSInteger int2 = int1 % 3600;
NSInteger minutes = int2/60;
NSInteger seconds = int2 % 60;
clockLabel.text = [NSString stringWithFormat:@"  %02d  :  %02d  :  %02d  :  %02d ", days,hours, minutes, seconds];

最终日期的值在设备上为零,但在模拟器上。

我的应用程序是通用应用程序的时间计算在iPhone设备上正常工作。任何想法或帮助

从nsdateformatter中删除' zzz '之后为什么以前的代码可以在iPhone而不是iPad上使用?从nsdateformatter删除时区并起作用的日期字符串。

最新更新