在Delphi中将UTC字符串转换为TDatetime

Irw*_*wan 6 delphi utc tdatetime

var
  tm : string;
  dt : tdatetime;

tm := '2009-08-21T09:11:21Z';
dt := ?
Run Code Online (Sandbox Code Playgroud)

我知道我可以手动解析它,但我想知道是否有任何内置函数或Win32 API函数来执行此操作?

Lar*_*s D 0

这看起来像是与 Internet 协议相关的活动,因此使用 Win32 API 执行此操作应该没有问题。但请注意,Windows 无法正确支持大约 20 年前的历史日期与 UTC 之间的转换 - Windows 的时区设置中根本没有足够的详细信息。