# Proxy\_set\_header X-Time (TIME)

**URL:** <https://www.ruby-forum.com/t/proxy-set-header-x-time-time/215593>\
**Category:** NGINX\
**Created:** [January 9, 2012, 6:44pm UTC](https://www.ruby-forum.com/t/proxy-set-header-x-time-time/215593 "2012-01-09T18:44:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [January 9, 2012, 6:44pm UTC](https://www.ruby-forum.com/t/proxy-set-header-x-time-time/215593/1 "2012-01-09T18:44:43Z")

</div>

Hi,

I want add Current Time or Request Time in my header.

Please let me know which variable I can use in,

add\_header X-Time $(TIME)  
proxy\_set\_header X-Time $(TIME)

Thanks,  
Hiren

Posted at Nginx Forum:

> **[proxy\_set\_header X-Time (TIME)](https://forum.nginx.org/read.php?2,220970,220970#msg-220970)**
>
> Hi, I want add Current Time or Request Time in my header. Please let me know which variable I can use in, add\_header X-Time $(TIME) proxy\_set\_header X-Time $(TIME) Thanks, Hiren

---

<div class="post-metadata">

**Author:** ![hirenshah.05](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8e8cbc/32.png) [@hirenshah.05](https://www.ruby-forum.com/u/hirenshah.05)\
**Post date:** [January 9, 2012, 8:18pm UTC](https://www.ruby-forum.com/t/proxy-set-header-x-time-time/215593/2 "2012-01-09T20:18:17Z")

</div>

you can use $time\_local in order to do that.

hirenshah.05 wrote in post #1040101:

> Hi,
> 
> I want add Current Time or Request Time in my header.
> 
> Please let me know which variable I can use in,
> 
> add\_header X-Time $(TIME)  
> proxy\_set\_header X-Time $(TIME)
> 
> Thanks,  
> Hiren
> 
> Posted at Nginx Forum:  
> [http://forum.nginx.org/read.php?2,220970,220970#msg-220970](http://forum.nginx.org/read.php?2,220970,220970#msg-220970)

---

<div class="post-metadata">

**Author:** ![hirenshah.05](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8e8cbc/32.png) [@hirenshah.05](https://www.ruby-forum.com/u/hirenshah.05)\
**Post date:** [January 9, 2012, 8:26pm UTC](https://www.ruby-forum.com/t/proxy-set-header-x-time-time/215593/3 "2012-01-09T20:26:16Z")

</div>

Thanks for your reply.

I tried that. But looks like $time\_local is only available for Log.

It does not recognize $time\_local in Server section.

May be I am missing something. Is there way to make these variable  
available in anywhere in nginx conf ?

Posted at Nginx Forum:

> **[Re: proxy\_set\_header X-Time (TIME)](https://forum.nginx.org/read.php?2,220970,220975#msg-220975)**
>
> Hi, I want add Current Time or Request Time in my header. Please let me know which variable I can use in, add\_header X-Time $(TIME) proxy\_set\_header X-Time $(TIME) Thanks, Hiren

---

<div class="post-metadata">

**Author:** ![hirenshah.05](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8e8cbc/32.png) [@hirenshah.05](https://www.ruby-forum.com/u/hirenshah.05)\
**Post date:** [January 9, 2012, 9:27pm UTC](https://www.ruby-forum.com/t/proxy-set-header-x-time-time/215593/4 "2012-01-09T21:27:59Z")

</div>

yeah that is a good idea to use lua-nginx module or if you have built  
your nginx with perl then you can have a look at this as well

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

It is pretty much the same idea as Brian indicated.

Brian A. wrote in post #1040119:

> something like:
> 
> set\_by\_lua $my\_time “return ngx.time()”;

---

<div class="post-metadata">

**Author:** ![hirenshah.05](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8e8cbc/32.png) [@hirenshah.05](https://www.ruby-forum.com/u/hirenshah.05)\
**Post date:** [January 9, 2012, 9:14pm UTC](https://www.ruby-forum.com/t/proxy-set-header-x-time-time/215593/5 "2012-01-09T21:14:44Z")

</div>

something like:

set\_by\_lua $my\_time “return ngx.time()”;

---

<div class="post-metadata">

**Author:** ![hirenshah.05](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8e8cbc/32.png) [@hirenshah.05](https://www.ruby-forum.com/u/hirenshah.05)\
**Post date:** [January 9, 2012, 10:11pm UTC](https://www.ruby-forum.com/t/proxy-set-header-x-time-time/215593/6 "2012-01-09T22:11:09Z")

</div>

Thanks for your help.

I found this,  
[http://wiki.nginx.org/HttpSsiModule#.24date\_gmt](http://wiki.nginx.org/HttpSsiModule#.24date_gmt)

I am using $date\_gmt variable.

Posted at Nginx Forum:

> **[Re: proxy\_set\_header X-Time (TIME)](https://forum.nginx.org/read.php?2,220970,220980#msg-220980)**
>
> Hi, I want add Current Time or Request Time in my header. Please let me know which variable I can use in, add\_header X-Time $(TIME) proxy\_set\_header X-Time $(TIME) Thanks, Hiren

---

<div class="post-metadata">

**Author:** ![hirenshah.05](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/8e8cbc/32.png) [@hirenshah.05](https://www.ruby-forum.com/u/hirenshah.05)\
**Post date:** [January 9, 2012, 10:01pm UTC](https://www.ruby-forum.com/t/proxy-set-header-x-time-time/215593/7 "2012-01-09T22:01:15Z")

</div>

Thanks Brian and Dhaval.

So there is no way other than installing additional module ??

Posted at Nginx Forum:

> **[Re: proxy\_set\_header X-Time (TIME)](https://forum.nginx.org/read.php?2,220970,220979#msg-220979)**
>
> Hi, I want add Current Time or Request Time in my header. Please let me know which variable I can use in, add\_header X-Time $(TIME) proxy\_set\_header X-Time $(TIME) Thanks, Hiren
