# Adding a TIME variable?

**URL:** <https://www.ruby-forum.com/t/adding-a-time-variable/144048>\
**Category:** NGINX\
**Created:** [July 24, 2008, 10:09pm UTC](https://www.ruby-forum.com/t/adding-a-time-variable/144048 "2008-07-24T22:09:33Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mike\_Harding](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@Mike\_Harding](https://www.ruby-forum.com/u/Mike_Harding)\
**Post date:** [July 24, 2008, 10:09pm UTC](https://www.ruby-forum.com/t/adding-a-time-variable/144048/1 "2008-07-24T22:09:33Z")

</div>

I am porting some apache rewrite rules that use the TIME variable (just  
unix epoch, seconds since 1/1/1970). What would be my best option for  
nginx?

I could

- modify the code to provide a $time variable
- use fgci
- use the embedded perl option
- proxy to an apache server

any other options? How much work would be involved with the first  
option? I am an accomplished C programmer and could provide patches  
back to the project…

- Mike H.

---

<div class="post-metadata">

**Author:** ![Mike\_Harding](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@Mike\_Harding](https://www.ruby-forum.com/u/Mike_Harding)\
**Post date:** [July 25, 2008, 4:14am UTC](https://www.ruby-forum.com/t/adding-a-time-variable/144048/2 "2008-07-25T04:14:14Z")

</div>

u can use a function “ngx\_time()” it return a time\_t int about seconds  
since 1/1/1970

---

<div class="post-metadata">

**Author:** ![Mike\_Harding](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@Mike\_Harding](https://www.ruby-forum.com/u/Mike_Harding)\
**Post date:** [July 25, 2008, 4:25am UTC](https://www.ruby-forum.com/t/adding-a-time-variable/144048/3 "2008-07-25T04:25:21Z")

</div>

And an idea, maybe you can add a time based access control in nginx  
rather  
than IP.  
for example , some admin pages can only access at work time.

2008/7/25 pf shineyear [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![Mike\_Harding](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/d6d6ee/32.png) [@Mike\_Harding](https://www.ruby-forum.com/u/Mike_Harding)\
**Post date:** [July 25, 2008, 7:19pm UTC](https://www.ruby-forum.com/t/adding-a-time-variable/144048/4 "2008-07-25T19:19:37Z")

</div>

How does that help with a rewrite rule?

I am leaning towards doing this on the back end, we still have apache  
back there…
