在Delphi中将UTC字符串转换为TDatetime
var
tm : string;
dt : tdatetime;
tm := '2009-08-21T09:11:21Z';
dt := ?
我知道我可以手动解析它,但我想知道是否有任何内置函数或 Win32 API 函数可以执行此操作?
var
tm : string;
dt : tdatetime;
tm := '2009-08-21T09:11:21Z';
dt := ?
I know I can parse it manually but I wonder if there is any built-in function or Win32 API function to do this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不明白为什么有那么多人不知道自己在说什么就胡言乱语?我必须做这种卑微的工作;它是一个 RAD 工具吗?不过,我有时发现 Delphi 具有真正精湛的架构。
http://编码。 derkeiler.com/Archive/Delphi/comp.lang.pascal.delphi.misc/2006-08/msg00190.html
I don't know why there are so many people shooting their mouth off when they don't know what they are talking about? I have to do this menial work; Is it a RAD tool? I sometimes find Delphi has a real superb architecture, though.
http://coding.derkeiler.com/Archive/Delphi/comp.lang.pascal.delphi.misc/2006-08/msg00190.html
如果您使用 Indy 10,其
StrInternetToDateTime()
和GMTToLocalDateTime()
函数(在IdGlobalProtocols
单元中)可以解析 ISO-8601 格式的字符串。If you are using Indy 10, its
StrInternetToDateTime()
andGMTToLocalDateTime()
functions (in theIdGlobalProtocols
unit) can parse ISO-8601 formatted strings.这看起来像是与 Internet 协议相关的活动,因此使用 Win32 API 执行此操作应该没有问题。但请注意,Windows 无法正确支持大约 20 年前的历史日期与 UTC 之间的转换 - Windows 的时区设置中根本没有足够的详细信息。
This looks like an internet protocol related activity, so you should have no problems in using the Win32 API for this. However note, that Windows does not correctly support conversion to/from UTC for historical dates that are more than approximately 20 years old - Windows simply doesn't have enough details in its time zone settings for that.