8
Delphi에서 다른 시간대의 현재 시간을 어떻게 얻을 수 있습니까? TidSNTP를 사용하는 경우 내 로캘에서 표준 시간대 만 제공합니다.Delphi의 다른 TimeZone에서 현재 시간을 얻으려면 어떻게해야합니까?
Delphi에서 다른 시간대의 현재 시간을 어떻게 얻을 수 있습니까? TidSNTP를 사용하는 경우 내 로캘에서 표준 시간대 만 제공합니다.Delphi의 다른 TimeZone에서 현재 시간을 얻으려면 어떻게해야합니까?
delphi-tzdb (Time Zone Database for Delphi)으로 현지 시간을 다른 시간대로 쉽게 변환 할 수 있습니다.
다음은 해당 documentation의 예입니다.
var
LSydney: TTimeZone;
LMadeUpLocalTime, LUniversalTime,
LSydneyTime: TDateTime;
begin
// Get the Sydney time zone
LSydney := TBundledTimeZone.GetTimeZone('Australia/Sydney');
// Encode a local date/time value -- 14th March 2009 at 12:45:00 PM
LMadeUpLocalTime := EncodeDateTime(2009, 03, 14, 12, 45, 00, 00);
// Find out what was the time in Sydney at that moment
LUniversalTime := TTimeZone.Local.ToUniversalTime(LMadeUpLocalTime);
LSydneyTime := LSydney.ToLocalTime(LUniversalTime);
WriteLn(Format('When in my time zone the time was %s, in Sydney it was %s.',
[DateTimeToStr(LMadeUpLocalTime), DateTimeToStr(LSydneyTime)]));
end;
이것은 훌륭한 델파이 리소스입니다. 또한 IANA 표준 시간대 데이터베이스를 기반으로하기 때문에 최신 데이터로 쉽게 업데이트 할 수 있습니다. 예를 들어 태평양 국가가 날짜 표시 줄을 넘나들거나 아르헨티나가 일광 절약 날짜와 규칙을 다시 변경하는 경우입니다. – frogb