# Set Time.zone to current user time zone

**URL:** <https://www.ruby-forum.com/t/set-time-zone-to-current-user-time-zone/181367>\
**Category:** Rails\
**Created:** [January 10, 2010, 11:32pm UTC](https://www.ruby-forum.com/t/set-time-zone-to-current-user-time-zone/181367 "2010-01-10T23:32:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![johnny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecb155/32.png) [@johnny](https://www.ruby-forum.com/u/johnny)\
**Post date:** [January 10, 2010, 11:32pm UTC](https://www.ruby-forum.com/t/set-time-zone-to-current-user-time-zone/181367/1 "2010-01-10T23:32:48Z")

</div>

I want to set the Time.zone to the user’s current time zone, I don’t  
want to store the timezone in user profile like many other solutions.  
How to do that?

Thanks

---

<div class="post-metadata">

**Author:** ![johnny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecb155/32.png) [@johnny](https://www.ruby-forum.com/u/johnny)\
**Post date:** [January 10, 2010, 11:37pm UTC](https://www.ruby-forum.com/t/set-time-zone-to-current-user-time-zone/181367/2 "2010-01-10T23:37:29Z")

</div>

hmm… doesn’t that come in the Request?

Or maybe current\_user.time\_zone?

Just a couple thoughts, I don’t really know.

[]'s  
Rodrigo D.

---

<div class="post-metadata">

**Author:** ![johnny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecb155/32.png) [@johnny](https://www.ruby-forum.com/u/johnny)\
**Post date:** [January 10, 2010, 11:39pm UTC](https://www.ruby-forum.com/t/set-time-zone-to-current-user-time-zone/181367/3 "2010-01-10T23:39:50Z")

</div>

Correct me if i am wrong, but current\_user.time\_zone will require you  
store the time\_zone under user profile.

---

<div class="post-metadata">

**Author:** ![johnny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ecb155/32.png) [@johnny](https://www.ruby-forum.com/u/johnny)\
**Post date:** [January 11, 2010, 11:20am UTC](https://www.ruby-forum.com/t/set-time-zone-to-current-user-time-zone/181367/4 "2010-01-11T11:20:54Z")

</div>

2010/1/10 Johnny S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> I want to set the Time.zone to the user’s current time zone, I don’t  
> want to store the timezone in user profile like many other solutions.  
> How to do that?

I believe this has been discussed a number of times and my  
understanding is that the only way to achieve it is via javascript and  
pass the data back to to the server (or better just use it in the  
browser if possible). Google will provide various suggestions such as

> **[Auto detect a time zone with JavaScript](http://www.onlineaspect.com/2007/06/08/auto-detect-a-time-zone-with-javascript/)**
>
> A blog about building stuff on the web by Josh Fraser

Colin
