# To\_xml and timezones

**URL:** <https://www.ruby-forum.com/t/to-xml-and-timezones/175153>\
**Category:** Rails\
**Created:** [September 9, 2009, 5:14am UTC](https://www.ruby-forum.com/t/to-xml-and-timezones/175153 "2009-09-09T05:14:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [September 9, 2009, 5:14am UTC](https://www.ruby-forum.com/t/to-xml-and-timezones/175153/1 "2009-09-09T05:14:53Z")

</div>

When i call model\_object.to\_xml, there is a DateTime field and it’s  
displayed as such: 2009-08-25T16:32:06Z

Is there anyway to modify the display format to say the format like  
Time.now.utc?, i.e. 2009-09-09 03:14:20 UTC

thanks

---

<div class="post-metadata">

**Author:** ![hangingclowns](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/b5e925/32.png) [@hangingclowns](https://www.ruby-forum.com/u/hangingclowns)\
**Post date:** [September 9, 2009, 6:58pm UTC](https://www.ruby-forum.com/t/to-xml-and-timezones/175153/2 "2009-09-09T18:58:22Z")

</div>

Allen W. wrote:

> When i call model\_object.to\_xml, there is a DateTime field and it’s  
> displayed as such: 2009-08-25T16:32:06Z
> 
> Is there anyway to modify the display format to say the format like  
> Time.now.utc?, i.e. 2009-09-09 03:14:20 UTC
> 
> thanks

Time formats in XML are standardized and Rails uses the standard. I  
would highly recommend you NOT change it. The model layer should not be  
responsible for date/time formats anyway. Let you views do their job.

[http://www.w3.org/TR/xmlschema-2/#dateTime](http://www.w3.org/TR/xmlschema-2/#dateTime)
