4

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

isapir
  • 21,295
  • 13
  • 115
  • 116

1 Answers1

6

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).

Bernard Rosset
  • 4,523
  • 6
  • 27
  • 29
  • i guess for php, it will be /*# config timefmt="%A, %d-%b-%Y %H:%M:%S %Z" */, but it doesn't seem to be working. – Satys Oct 09 '16 at 16:00
  • SSI parse *responses* and interpret (textual) commands there. There is no notion of backend, thus no PHP... – Bernard Rosset Oct 10 '16 at 08:07