lundi 1 décembre 2014

How to calculate NStimeZone differeces

Hi 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




Aucun commentaire:

Enregistrer un commentaire