【发布时间】:2013-09-29 17:38:51
【问题描述】:
如何使用 Lua 脚本获取当前 UTC 时间并将其转换为人类可读的文本?
【问题讨论】:
如何使用 Lua 脚本获取当前 UTC 时间并将其转换为人类可读的文本?
【问题讨论】:
试试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))
【讨论】:
!的示例代码:cutTime = 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))