# Timzones, UTC, and to\_xml()

**URL:** <https://www.ruby-forum.com/t/timzones-utc-and-to-xml/62887>\
**Category:** Rails\
**Created:** [June 9, 2006, 2:17am UTC](https://www.ruby-forum.com/t/timzones-utc-and-to-xml/62887 "2006-06-09T02:17:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zack\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb9ed0/32.png) [@Zack\_C](https://www.ruby-forum.com/u/Zack_C)\
**Post date:** [June 9, 2006, 2:17am UTC](https://www.ruby-forum.com/t/timzones-utc-and-to-xml/62887/1 "2006-06-09T02:17:32Z")

</div>

Does anyone know a good way to hook into the AR to\_xml() method to  
allow for adjusting datetimes to a user’s timezone?

Basically I want a user to be able dump all their data before  
cancelling an account. I store all datetime info as UTC as per the  
recommendations of Jamis B. and Scott B. in the Rails Recipe  
article “Dealing with Timezones”. Come to think of it I bet 37Signals  
already has figured out a way to do this as they allow users to dump  
data…

Any help would be much appreciated.

Thanks,  
Zack

---

<div class="post-metadata">

**Author:** ![Zack\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb9ed0/32.png) [@Zack\_C](https://www.ruby-forum.com/u/Zack_C)\
**Post date:** [June 9, 2006, 2:51am UTC](https://www.ruby-forum.com/t/timzones-utc-and-to-xml/62887/2 "2006-06-09T02:51:53Z")

</div>

Zack C. wrote:

> Any help would be much appreciated.  
> What is the intended use of the data when they get it?

It seems safer to give it to them in UTC instead of their timezone, no  
telling  
what they may do with it, so you may be saving them hassle later on.

Also, what if they move timezones after they export it and then they try  
to  
import it somewhere and the times will be wrong.

Regards,  
Blair

–  
Blair Z., Ph.D.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Subversion training, consulting and support  
[http://www.orcaware.com/svn/](http://www.orcaware.com/svn/)

---

<div class="post-metadata">

**Author:** ![Zack\_C](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/eb9ed0/32.png) [@Zack\_C](https://www.ruby-forum.com/u/Zack_C)\
**Post date:** [June 9, 2006, 4:05pm UTC](https://www.ruby-forum.com/t/timzones-utc-and-to-xml/62887/3 "2006-06-09T16:05:45Z")

</div>

Blair,  
I understand this argument and I’ve thought the pros and cons.  
Still, converting makes sense to me as not to confuse the user by  
having all the times off by whatever their Timezone offset is…

I know I can always loop through the objects and convert if the AR  
attribute is\_a? Time… but I love those ruby one-liners…

Zack
