如何在Lua脚本中获取当前UTC时间? [英] How can I get the current UTC time in a Lua script?

查看:46
本文介绍了如何在Lua脚本中获取当前UTC时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

推荐答案

尝试 os.date("!%c").这里的表示UTC,而%c 表示标准格式的完整日期.有关其他选项,请参见 http://www.lua.org/manual/5.2/manual.html#pdf-os.date .

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))

这篇关于如何在Lua脚本中获取当前UTC时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆