我如何在Lua脚本中获得当前的UTC时间?

如何使用 Lua 脚本获取当前的 UTC 时间并将其转换为人类可读的文本?

点赞
用户107090
用户107090

尝试使用 os.date("!%c")。在这里,! 表示 UTC,%c 表示标准格式下的完整日期。欲了解其他选项,请参阅http://www.lua.org/manual/5.2/manual.html#pdf-os.date

curTime = os.time(); print("os.date(): "..os.date('%Y-%m-%d-%H:%M:%S', curTime));
print("os.date(!): "..os.date('!%Y-%m-%d-%H:%M:%S GMT', curTime))
2013-09-24 16:44:47