How to set date format for nginx $ date_local

According to the docs, you can set the date format in nginx using a command config timefmt

, but I cannot find any documentation / example where and how to set this.

By default, a string is displayed, such as "Sunday, 26-Oct-2014 21:05:24 Pacific Daylight Time", and I want to change it to yyyyMMdd

I am running nginx on Windows if it matters.

thank

+3


source to share


1 answer


You shouldn't read the ngx_http_ssi_module documentation (especially its ' SSI Commands Section ): it describes the format of the commands.

You need to set the directive ssi

in on

the context in which you want SSI commands to be processed, then you need to serve the files containing these commands there.

For example:

server {
    listen 8000;
    index index.txt;

    location / {
        ssi on;
    }
}

      



The variable $date_local

indicates that it should be configured using a command config

by setting its parameter timefmt

.

You just need to serve up files that will send commands back, like index.txt

:

<!--# config timefmt="%A, %d-%b-%Y %H:%M:%S %Z" -->

      

The format used by the parameter timefmt

is one of the <standard functions strftime

(as stated in the documentation).

+5


source







All Articles