# How does nginx get the TimeZone of local system while compile & install?

**URL:** <https://www.ruby-forum.com/t/how-does-nginx-get-the-timezone-of-local-system-while-compile-install/211241>\
**Category:** NGINX\
**Created:** [August 30, 2011, 1:54pm UTC](https://www.ruby-forum.com/t/how-does-nginx-get-the-timezone-of-local-system-while-compile-install/211241 "2011-08-30T13:54:01Z")\
**Posts on this page:** 5\
**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:** [August 30, 2011, 1:54pm UTC](https://www.ruby-forum.com/t/how-does-nginx-get-the-timezone-of-local-system-while-compile-install/211241/1 "2011-08-30T13:54:01Z")

</div>

hi,ALL  
it’s me,i come here again and post my problem here.  
last weekend,i uninstalled the old version of nginx (1.0.4),and  
installed the newest development version 1.1.1 on my VPS.

but,unfortunately that i found that nginx still used the UTC timezone  
not CST locally.

that’s strange.Can someone help me fix the problem? Thanks a lot 🙂

–  
Best regards,  
Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED** )

Using Gmail? Please read this important notice:  
[Gmail — Free Software Foundation — Working together for free software](http://www.fsf.org/campaigns/jstrap/gmail?10073).

---

<div class="post-metadata">

**Author:** ![Sharl.Jimh.Tsin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@Sharl.Jimh.Tsin](https://www.ruby-forum.com/u/Sharl.Jimh.Tsin)\
**Post date:** [August 30, 2011, 2:15pm UTC](https://www.ruby-forum.com/t/how-does-nginx-get-the-timezone-of-local-system-while-compile-install/211241/2 "2011-08-30T14:15:38Z")

</div>

Hello!

On Tue, Aug 30, 2011 at 07:53:31PM +0800, Sharl.Jimh.Tsin wrote:

> hi,ALL  
> it’s me,i come here again and post my problem here.  
> last weekend,i uninstalled the old version of nginx (1.0.4),and  
> installed the newest development version 1.1.1 on my VPS.
> 
> but,unfortunately that i found that nginx still used the UTC timezone  
> not CST locally.
> 
> that’s strange.Can someone help me fix the problem? Thanks a lot 🙂

By default nginx uses timezone as set during startup (either in TZ  
environment variable, or system’s default one).

Looks like you just have it set to UTC while starting nginx (only  
set CST for your particular user?).

If in doubt how to correctly set timezone on your system, you may  
do so explicitly in nginx config via “env” directive (see [1]):

```
env TZ=CST;

```

(note that using CST explicitly may not be a good idea, as it  
won’t account for daylight saving changes if there are any in your  
area, you may want to use something like “TZ=America/Menominee”  
instead)

[1] [GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com · GitHub](http://wiki.nginx.org/CoreModule#env)

Maxim D.

---

<div class="post-metadata">

**Author:** ![Sharl.Jimh.Tsin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@Sharl.Jimh.Tsin](https://www.ruby-forum.com/u/Sharl.Jimh.Tsin)\
**Post date:** [August 30, 2011, 5:51pm UTC](https://www.ruby-forum.com/t/how-does-nginx-get-the-timezone-of-local-system-while-compile-install/211241/3 "2011-08-30T17:51:52Z")

</div>

Hello!

On Tue, Aug 30, 2011 at 08:29:56PM +0800, Sharl.Jimh.Tsin wrote:

[…]

> and to define it in nginx.conf file via “env” probably not work at all,i  
> tried it before.for example “env TZ=Asia/Shanghai”.

Which OS do you use, Linux? This works perfectly on FreeBSD, but  
it looks like not on Linux as it doesn’t check updated TZ  
environment on localtime\_r() calls and requires explicit tzset().  
I’ll take a more closer look as time permits.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Sharl.Jimh.Tsin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@Sharl.Jimh.Tsin](https://www.ruby-forum.com/u/Sharl.Jimh.Tsin)\
**Post date:** [August 30, 2011, 2:30pm UTC](https://www.ruby-forum.com/t/how-does-nginx-get-the-timezone-of-local-system-while-compile-install/211241/4 "2011-08-30T14:30:27Z")

</div>

在 2011-08-30二的 16:14 +0400，Maxim D.写道：

> > not CST locally.  
> > do so explicitly in nginx config via “env” directive (see [1]):  
> > Maxim D.
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

OK,thanks for your quickly reply,Maxim D..

When i heard that nginx will detect the TimeZone variable at startup,i  
am so happy!

Maybe i have set CST timezone for my own user,not ALL users.i will try  
to set it to Global later.

and to define it in nginx.conf file via “env” probably not work at all,i  
tried it before.for example “env TZ=Asia/Shanghai”.

–  
Best regards,  
Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED** )

Using Gmail? Please read this important notice:  
[Gmail — Free Software Foundation — Working together for free software](http://www.fsf.org/campaigns/jstrap/gmail?10073).

---

<div class="post-metadata">

**Author:** ![Sharl.Jimh.Tsin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@Sharl.Jimh.Tsin](https://www.ruby-forum.com/u/Sharl.Jimh.Tsin)\
**Post date:** [August 31, 2011, 4:39am UTC](https://www.ruby-forum.com/t/how-does-nginx-get-the-timezone-of-local-system-while-compile-install/211241/5 "2011-08-31T04:39:32Z")

</div>

在 2011-08-30二的 19:51 +0400，Maxim D.写道：

> it looks like not on Linux as it doesn’t check updated TZ  
> environment on localtime\_r() calls and requires explicit tzset().  
> I’ll take a more closer look as time permits.
> 
> Maxim D.
> 
> * * *
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://mailman.nginx.org/mailman/listinfo/nginx)

Yes,exactly it is CentOS GNU/Linux distro.

and i am so sorry that reply you so later.

–  
Best regards,  
Sharl.Jimh.Tsin (From China **Obviously Taiwan INCLUDED** )

Using Gmail? Please read this important notice:  
[Gmail — Free Software Foundation — Working together for free software](http://www.fsf.org/campaigns/jstrap/gmail?10073).
