如何设置nginx $ date_local的日期格式

isa*_*pir 3 configuration config nginx

根据文档,你可以使用命令在nginx中设置日期格式,config timefmt但是我找不到关于在何处或如何设置它的任何文档/示例.

默认显示一个字符串,如"Sunday,26-Oct-2014 21:05:24 Pacific Daylight Time",我想将其更改为 yyyyMMdd

我在Windows上运行nginx,如果这有所不同.

谢谢

Ber*_*set 5

您不能正确阅读ngx_http_ssi_module文档(特别是其"SSI命令"部分):它解释了命令格式.

您需要在您希望解析SSI命令的上下文中设置ssi指令on,然后您需要提供包含这些命令的文件.

例如:

server {
    listen 8000;
    index index.txt;

    location / {
        ssi on;
    }
}
Run Code Online (Sandbox Code Playgroud)

$date_local变量表明必须config通过设置其timefmt参数来配置命令.

您只需要提供将要发回命令的文件,例如index.txt:

<!--# config timefmt="%A, %d-%b-%Y %H:%M:%S %Z" -->
Run Code Online (Sandbox Code Playgroud)

timefmt参数使用的格式是strftime标准C函数之一(如文档所述).