# Time.parse and some weird defassage with timezone

**URL:** <https://www.ruby-forum.com/t/time-parse-and-some-weird-defassage-with-timezone/161238>\
**Category:** Rails\
**Created:** [February 24, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/time-parse-and-some-weird-defassage-with-timezone/161238 "2009-02-24T17:02:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andres\_Paglayan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8491ac/32.png) [@Andres\_Paglayan](https://www.ruby-forum.com/u/Andres_Paglayan)\
**Post date:** [February 24, 2009, 5:02pm UTC](https://www.ruby-forum.com/t/time-parse-and-some-weird-defassage-with-timezone/161238/1 "2009-02-24T17:02:57Z")

</div>

Hi,

I have a strange case,  
my system clock is set to utc and eastern time (-5)

rails is configured to use eastern time

timestamps on the database work as expected,  
meaning they are stored in utc

but by hand time entries are 2 hours behind, (why on earth two?)

i.e  
Time.parse(“2008-02-24 4 pm”) will return Tue Feb 24 16:00:00 -0500 2009  
but will store it in the database as 19:00 instead of 21:00 hrs (utc  
speaking)

Any clues?

---

<div class="post-metadata">

**Author:** ![Andres\_Paglayan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8491ac/32.png) [@Andres\_Paglayan](https://www.ruby-forum.com/u/Andres_Paglayan)\
**Post date:** [February 24, 2009, 5:50pm UTC](https://www.ruby-forum.com/t/time-parse-and-some-weird-defassage-with-timezone/161238/2 "2009-02-24T17:50:52Z")

</div>

What happens if you do this:

puts( Time.parse(“2008-02-24 4 pm”).utc )

Do you get the correct UTC time?

- 

Maurício Linhares  
[http://alinhavado.wordpress.com/](http://alinhavado.wordpress.com/) (pt-br) | [http://blog.codevader.com/](http://blog.codevader.com/)  
(en)

---

<div class="post-metadata">

**Author:** ![Andres\_Paglayan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/8491ac/32.png) [@Andres\_Paglayan](https://www.ruby-forum.com/u/Andres_Paglayan)\
**Post date:** [March 23, 2009, 2:54am UTC](https://www.ruby-forum.com/t/time-parse-and-some-weird-defassage-with-timezone/161238/3 "2009-03-23T02:54:59Z")

</div>

On Feb 24, 10:49 am, Maurício Linhares [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> What happens if you do this:
> 
> puts( Time.parse(“2008-02-24 4 pm”).utc )
> 
> Do you get the correct UTC time?

Brigado Mauricio for the replay, yep,  
this was on scraped data, ashamed to say that I wasn’t checking its  
integrity,  
when i got the data like this: yyyy-mm-ddhh\_mm (without space between  
dd and hh),  
interestingly enough, after 2,200 parses the parser starts the 2 hour  
drift,  
(I am making sure that the date string comes properly formatted now)  
but still, an interesting ‘feature’
