Skip to content

Instantly share code, notes, and snippets.

Last active Aug 15, 2019
What would you like to do?
[Openresty] %z だと nginx の iso_8601 の format と異なるので(: がない)、format を揃える
now = os.time()
offset = os.difftime(os.time("*t", now)), os.time("!*t", now)))
hour = math.floor(offset / 3600)
min = (offset / 60) % 60
timezone = nil
if offset < 0 then
timezone = string.format("-%02d:%02d", hour, min)
timezone = string.format("+%02d:%02d", hour, min)
ngx.say("%Y-%m-%dT%T", ngx.req.start_time()) .. timezone)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment