How can I get the current UTC time using a Lua script and convert it to human readable text?

有帮助吗?

解决方案

Try os.date("!%c"). Here ! means UTC and %c means full date in standard format. For other options, see 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))
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top