2009-09-24 6 views
3

두 시간대 사이의 시간 차이를 계산하는 데 문제가 있습니다.두 위치 간의 시간차를 계산하는 방법

내가 A 위치에 있다면 나는 위도와 경도와 현재 시간을 알고 있습니다. B 위치로 이동합니다. 위도와 경도 및 현재 시간을 알고 있습니다. (UTC에서) 두 현재 포인트 사이의 시간 차이 ..

+0

그냥 위치 B의 현재 시간에서의 위치 A의 현재 시간을 빼기 : http://www.ip2location.com/

당신이 이런 일을 할 것 실제 변환 작업을 수행하려면 아니면 내가 오해하고있는거야? – artagnon

+0

그래, 그는 내가 ... 내가 시간대에이 방법을 한 의미 .. 경도에 의해 그것을 할 싶어 통해 UR 대답을 – Jacob

답변

4

은 우선 국가 및시 /도를 얻을 긴 위도/변환 데이터베이스 또는 라이브러리를 얻을 수를 계산하는 방법

. 그런 다음 NSTimeZone 클래스를 사용하여 특정 국가의 시간대를 검색합니다. 당신은 즉, 여러 사이트에서 같은 데이터베이스를 구입할 수

NSTimeZone *sourceTimeZone = 
    [NSTimeZone timeZoneWithAbbreviation: @"GMT"]; 
NSTimeZone *destinationTimeZone = 
    [NSTimeZone timeZoneWithAbbreviation: @"EST"]; 

NSInteger sourceSeconds = 
    [sourceTimeZone secondsFromGMTForDate:date]; 
NSInteger destinationSeconds = 
    [destinationTimeZone secondsFromGMTForDate:date]; 
NSTimeInterval interval = destinationSeconds - sourceSeconds; 
+0

헤이 감사 latitud NSTimeZone * sourceTimeZone = [NSTimeZone timeZoneWithName : [있는 NSString stringWithFormat : % "@ @ ", @"America/Menominee "]]; \t NSTimeZone * destinationTimeZone = [NSTimeZone timeZoneWithName : [NSString stringWithFormat : @ "% @", @ "America/Juneau"]]]; \t \t NSDate * date1 = [NSDate date]; \t NSInteger sourceSeconds = [sourceTimeZone secondsFromGMTForDate : date1]; \t NSInteger destinationSeconds = [destinationTimeZone secondsFromGMTForDate : date1]; \t NSTimeInterval 간격 = destinationSeconds - sourceSeconds; 다시 감사합니다 – Sneha

+0

그 위치에있는 낮 시간과 밤 시간을 계산하는 방법을 알고 있습니까 – Sneha

+0

각 장소에서 일몰과 일출 시간이 달라지기 때문입니다 http://www.mindspring.com/~cavu/sunset .html 나는이 양식을 우리가 실제로 차이점을 발견하고 모두 그것을 구현하는 방법을 몰라 : ( – Sneha

관련 문제