问题
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.
The default shows a string like "Sunday, 26-Oct-2014 21:05:24 Pacific Daylight Time" and I want to change it to yyyyMMdd
I'm running nginx on Windows if that makes a difference.
Thank you
回答1:
You must not have read the ngx_http_ssi_module documentation properly (especially its 'SSI Commands' section): it explains the commands format.
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.
For example:
server {
listen 8000;
index index.txt;
location / {
ssi on;
}
}
The $date_local variable states that it must be configured with the config
command, by settings its timefmt
parameter.
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" -->
The format being used by the timefmt
parameter is the one of the strftime standard C function (as the documentation states).
来源:https://stackoverflow.com/questions/26581098/how-to-set-date-format-for-nginx-date-local