FYI: https://qiita.com/sfujiwara/items/b227b3ca6a1e8f104bc9
$ date +%z
+0900
$ /path/to/resty start_time.lua
1970-01-01T09:00:00+09:00
FYI: https://qiita.com/sfujiwara/items/b227b3ca6a1e8f104bc9
$ date +%z
+0900
$ /path/to/resty start_time.lua
1970-01-01T09:00:00+09:00
| 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) |