# Timezone support breaks \_before\_type\_cast method

**URL:** <https://www.ruby-forum.com/t/timezone-support-breaks-before-type-cast-method/144499>\
**Category:** Rails\
**Created:** [July 30, 2008, 11:02am UTC](https://www.ruby-forum.com/t/timezone-support-breaks-before-type-cast-method/144499 "2008-07-30T11:02:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sean-lerner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ccd318/32.png) [@sean-lerner](https://www.ruby-forum.com/u/sean-lerner)\
**Post date:** [July 30, 2008, 11:02am UTC](https://www.ruby-forum.com/t/timezone-support-breaks-before-type-cast-method/144499/1 "2008-07-30T11:02:48Z")

</div>

Some code in my current project validates date time format using  
\_before\_type\_cast method. But after adding "config.time\_zone = “UTC” in  
environment.rb, we can’t get string raw values of some date time columns  
using \_before\_type\_cast.  
for example,

> > p = Person.new(:name =\> ‘sean’, :birthday =\> ‘1989-01-23’)  
> > p.birthday\_before\_type\_cast  
> > Mon, 23 Jan 1989 00:00:00 UTC 00:00  
> > p.birthday\_before\_type\_cast.class  
> > =\> ActiveSupport::TimeWithZone

now birthday\_before\_type\_cast returns value of type:  
“ActiveSupport::TimeWithZone”.

Is there a method to get the raw value of date time column in this case?  
By the way, is this a bug of rails 2.1.0 or the right behavior?

Thanks.
