9951 explained code solutions for 126 technologies


nginx-luaHow to get YYYY-MM-DD date


server {
  location / {
    content_by_lua_block {
      local date = os.date("!%Y-%m-%d")
      ngx.say(date)
    }
  }
}ctrl + c
content_by_lua_block

nginx-lua module directive to specify block of Lua code

os.date

returns date/time in a given format

ngx.say

output given text to client