Is there a way to get the current time in nginx?

nginx

Solution

You can use variables from SSI modulе: $date_gmt and $date_local

proxy_set_header THE-TIME $date_gmt;

http://nginx.org/en/docs/http/ngx_http_ssi_module.html#variables

Problem

I am trying to inject the time of an nginx server into an HTTP header. I am able to add to an HTTP header, like so: ``` proxy_set_header HELLO-WORLD 'something'; ``` But now, I want to be able to inject the time into an HTTP header, something that looks like this: ``` proxy_set_header THE-TIME $time_var; ``` Or something like that. Would that be possible?

Original source