Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

GMT versus LocalTimeZone

Posted on 2002-06-26
2
Medium Priority
?
342 Views
Last Modified: 2010-04-04
Hi,

I need some help with the following questions

How to convert from
   1) GMT to LocalTime
   2) LocalTime to GMT

E.g.  during the summer, the local time in Brussels
is GMT + 2, during the winter it is GMT + 1
-->  17:20 hour in Brussels (during the summer) is the same as 15:20 GMT

I would like some sample code showing me the time in the different timezones (like example above)

best regards,

Daniel
0
Comment
Question by:KinnaerD
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 8

Expert Comment

by:Cesario
ID: 7111710
function UTCOffset: Single;

var
  TZI: TTimeZoneInformation;

begin
  GetTimeZoneInformation(TZI);
  Result := TZI.Bias / 60 / 24;
end;

function LocalDateTimeToUTC(const LocalDateTime: TDateTime): TDateTime;

begin
  Result := LocalDateTime + UTCOffset;
end;

function UTCToLocalDateTime(const UTC: TDateTime): TDateTime;

begin
  Result := UTC - UTCOffset;
end;

best regards

Cesario
0
 
LVL 8

Accepted Solution

by:
Cesario earned 600 total points
ID: 7111725
uuups please change this function:

// GetTimeZoneBias
function UTCOffset: TDateTime;
var
  TZI: TTimeZoneInformation;
begin
  case GetTimeZoneInformation(TZI) of
    TIME_ZONE_ID_STANDARD : Result := (TZI.Bias + TZI.StandardBias) / 1440;
    TIME_ZONE_ID_DAYLIGHT : Result := (TZI.Bias + TZI.DaylightBias) / 1440;
    TIME_ZONE_ID_UNKNOWN  : Result := TZI.Bias / 1440;
  else
    RaiseLastWin32Error;
  end;
end;


Best Regards

Cesario
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question