Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active August 15, 2019 03:28
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkuchiki/1900c83181232d05574c to your computer and use it in GitHub Desktop.
Save tkuchiki/1900c83181232d05574c to your computer and use it in GitHub Desktop.
[Openresty] %z だと nginx の iso_8601 の format と異なるので(: がない)、format を揃える
now = os.time()
offset = os.difftime(os.time(os.date("*t", now)), os.time(os.date("!*t", now)))
hour = math.floor(offset / 3600)
min = (offset / 60) % 60
timezone = nil
if offset < 0 then
timezone = string.format("-%02d:%02d", hour, min)
else
timezone = string.format("+%02d:%02d", hour, min)
end
ngx.say(os.date("%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