Timestamp to ISO 8601 in Lua

ⅰ亾dé卋堺 提交于 2019-12-12 10:32:01

问题


How would you convert a timestamp to an ISO 8601 format (such as 2009-01-28T21:49:59.000Z) in Lua?

I'm specifically trying to do it by using the HttpLuaModule in Nginx.


回答1:


Try os.date("!%Y-%m-%dT%TZ") or os.date("!%Y-%m-%dT%TZ",t) if t has the date in seconds since the epoch.




回答2:


Or you can use:

local now_date_time = os.date("!%Y%m%dT%H%M%S") --> For date_time: 20191015T042028Z

local now_date = os.date("!%Y%m%d") --> For only date: 20191015


来源:https://stackoverflow.com/questions/20131891/timestamp-to-iso-8601-in-lua

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!