跳到主要内容

DateTime():utc()

将 DateTime 对象的时区转换为 UTC。

签名​

utc(): DateTime

返回值​

  • 类型:DateTime
  • 当前的 DateTime 实例,其时区已设置为 UTC,可用于方法链式调用。

示例​

local now = DateTime()
toast("Local time: " .. now:format("yyyy-MM-dd HH:mm:ss Z"))

now:utc()
toast("UTC time: " .. now:format("yyyy-MM-dd HH:mm:ss Z"))