如何使用 D 获取当前 UTC 0 时间?

How to get current UTC 0 time with D?

我需要获取当前 UTC 0 时间。

我已经阅读了 Phobos datetime 文档,看起来我需要这部分:

Clock.currTime will return the current time as a SysTime. To convert a SysTime to a Date or DateTime, simply cast it. To convert a Date or DateTime to a SysTime, use SysTime's constructor, and pass in the intended time zone with it (or don't pass in a TimeZone, and the local time zone will be used).

如果我没看错的话,我需要 1. 获取当前的 SysTime。 2. 将其转换为 DateTime 3. 将结果 DateTime 转换为 LocalTime (UTC?)。

任何人都可以给我任何示例如何获取当前的 UTC 0 时间吗?

您可以将 TimeZone 参数传递给 Clock.currTime

所以你可以调用 auto time = Clock.currTime(UTC());

这将是 SysTime 当前 UTC 时间