Guest User

Untitled

a guest
Jul 17th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. - (NSDate*) convertToUTC:(NSDate*)sourceDate
  2. {
  3. NSTimeZone* currentTimeZone = [NSTimeZone localTimeZone];
  4. NSTimeZone* utcTimeZone = [NSTimeZone timeZoneWithAbbreviation:@"UTC"];
  5.  
  6. NSInteger currentGMTOffset = [currentTimeZone secondsFromGMTForDate:sourceDate];
  7. NSInteger gmtOffset = [utcTimeZone secondsFromGMTForDate:sourceDate];
  8. NSTimeInterval gmtInterval = gmtOffset - currentGMTOffset;
  9.  
  10. NSDate* destinationDate = [[[NSDate alloc] initWithTimeInterval:gmtInterval sinceDate:sourceDate] autorelease];
  11. return destinationDate;
  12. }
Add Comment
Please, Sign In to add comment