如何为Nginx $ date_local设置日期格式 [英] How to set date format for nginx $date_local

查看:689
本文介绍了如何为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 指令设置为在上下文中,您希望解析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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆