nginxluatimestampiso8601date-conversion

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.


Solution

  • 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.