Skip to content

Latest commit

 

History

History
54 lines (40 loc) · 1.11 KB

README.md

File metadata and controls

54 lines (40 loc) · 1.11 KB

Name

lua-resty-ntp - Get utc time from ntp server for ngx_lua and LuaJIT

Table of Contents

Description

This library requires the ngx_lua module, and LuaJIT 2.0.

Synopsis

    # nginx.conf:

    lua_package_path "/path/to/lua-resty-string/lib/?.lua;;";
    resolver 119.29.29.29;
    server {
        location = /test {
            content_by_lua_block {
                local ntp = require "resty.ntp"
                -- ntp.utctime(ntp_server, retry , timeout)
                local utctime,err =  ntp.utctime("pool.ntp.org", 3, 1000)
                if utctime then
                    ngx.say("utctime:",utctime)
                else
                    ngx.say("failed to get utctime: ",err)
                end           
            }
        }
    }

Author

Jason zhu (朱茂海) [email protected]

See Also