Timestamp to ISO 8601 in Lua
问题 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