9951 explained code solutions for 126 technologies


nginx-luaHow to convert unix timestamp to date time


server {
  location / {
    content_by_lua_block {
      local date_time = os.date("!%Y-%m-%d %H:%M", 1647900352)
      ngx.say(date_time)
    }
  }
}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

1647900352

pass unix timestamp as a second argument

ngx.say

output given text to client