2

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
venkipar
  • 141
  • 1
  • 2
  • 7
  • i got exact value .. i forget to convert to hours ... NSDate* sourceDate = [NSDate date]; NSTimeZone* sourceTimeZone = [NSTimeZone timeZoneWithName:[[arrayData objectAtIndex:0] objectForKey:@"timeZone"]];NSTimeZone* destinationTimeZone = [NSTimeZone localTimeZone];NSInteger sourceGMTOffset = [sourceTimeZone secondsFromGMTForDate:sourceDate]; NSInteger destinationGMTOffset= [destinationTimeZone secondsFromGMTForDate:sourceDate];NSTimeInterval interval = destinationGMTOffset - sourceGMTOffset;long hours = interval/3600; long Delt=hours+Delta; – venkipar Dec 02 '14 at 05:48
  • One possible problem: I don’t think that’s how Calcutta is spelled – Noah Witherspoon Dec 02 '14 at 06:05
  • Thanks .. Noah.. its my edit problem.. – venkipar Dec 02 '14 at 06:07

0 Answers0