如何为Nginx $ date_local设置日期格式 [英] How to set date format for nginx $date_local
问题描述
根据文档,您可以在nginx中设置日期格式使用命令config timefmt
,但是我找不到任何有关在何处或如何进行设置的文档/示例.
According to the docs you can set the date format in nginx with the command config timefmt
but I can't find any documentation/example on where or how to set that.
默认显示一个字符串,例如"Sunday,26-Oct-2014 21:05:24 Pacific Daylight Time",我想将其更改为yyyyMMdd
The default shows a string like "Sunday, 26-Oct-2014 21:05:24 Pacific Daylight Time" and I want to change it to yyyyMMdd
如果有帮助,我将在Windows上运行nginx.
I'm running nginx on Windows if that makes a difference.
谢谢
推荐答案
您必须尚未阅读"SSI命令"部分):它说明了命令格式.
You must not have read the ngx_http_ssi_module documentation properly (especially its 'SSI Commands' section): it explains the commands format.
您需要将 ssi
指令设置为
You need to set the ssi
directive to on
in the context you wish SSI commands to be parsed, then you need to serve files there which contains those commands.
例如:
server {
listen 8000;
index index.txt;
location / {
ssi on;
}
}
$date_local
变量指出必须对其进行配置通过设置timefmt
参数来设置config
命令.
您只需要提供可将命令发回的文件,例如index.txt
:
You just need to serve files which will send commands back, such as index.txt
:
<!--# config timefmt="%A, %d-%b-%Y %H:%M:%S %Z" -->
timefmt
参数使用的格式是 strftime
标准C函数(如文档所述).
The format being used by the timefmt
parameter is the one of the strftime
standard C function (as the documentation states).
这篇关于如何为Nginx $ date_local设置日期格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!