How to calculate NStimeZone differences

156 views Asked by At

Currently I am trying to sync up time with server time. Currently I am in India(IST) getting time zone and converting into GMT format and calculating timeStamp and finding delta value with server time and using that timestamp .. thats working fine.. for me..

Now I am changing the time zone and calculating timeInterval in Between existing tiemzone and new timezone and appending into delta value but not getting properly I am getting time interval like 19800

    NSDate* sourceDate1 = [NSDate date];
    NSTimeZone* sourceTimeZone1 = [NSTimeZone timeZoneWithAbbreviation:@"Asia/Clacutta"];
    NSTimeZone* destinationTimeZone1 = [NSTimeZone localTimeZone];
            NSInteger sourceGMTOffset1 = [sourceTimeZone1 secondsFromGMTForDate:sourceDate1];
    NSInteger destinationGMTOffset1= [destinationTimeZone1 secondsFromGMTForDate:sourceDate1];
    NSTimeInterval interval1 = destinationGMTOffset1 - sourceGMTOffset1;
    NSDate* destinationDate = [[NSDate alloc] initWithTimeInterval:interval1 sinceDate:sourceDate1];

long Delt=interval1+Delta;

I am not getting current result .. is this i am trying right way? or any other thing I need to change?

0

There are 0 answers