Convert TDateTime to Another Time Zone Regardless of Local Time Zone

后端 未结 3 1244
庸人自扰
庸人自扰 2021-02-10 23:53

Regardless of what the user\'s local time zone is set to, using Delphi 2007, I need to determine the time (TDateTime) in the Eastern time zone.

How can I do that? Of co

3条回答
  •  不知归路
    2021-02-11 00:32

    TDateTime does not have any time zone information (it is just a double - date as whole number, time as decimal), so you would need that separately. You would need your own logic for DST as well, I don't believe there is any in Delphi. Then use the IncHour function in DateUtils.pas to alter the TDateTime to the Eastern Timezone.

    There are probably web services that will do this for you. Does your application need to be self contained, or can it connect to the web to do it?

提交回复
热议问题