# Import utc in Time

**URL:** <https://www.ruby-forum.com/t/import-utc-in-time/175624>\
**Category:** Ruby\
**Created:** [September 16, 2009, 6:12pm UTC](https://www.ruby-forum.com/t/import-utc-in-time/175624 "2009-09-16T18:12:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![stratboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/838e76/32.png) [@stratboy](https://www.ruby-forum.com/u/stratboy)\
**Post date:** [September 16, 2009, 6:12pm UTC](https://www.ruby-forum.com/t/import-utc-in-time/175624/1 "2009-09-16T18:12:23Z")

</div>

Hi, i’m using facebooker for receiving facebook’s events.  
I receive the time of the event in utc format.

how can i import it in a Time object

in other words

a= Time.now.utc

how can i import a in a Time object??

this not works  
Time.parse(a)

thanks

---

<div class="post-metadata">

**Author:** ![stratboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/838e76/32.png) [@stratboy](https://www.ruby-forum.com/u/stratboy)\
**Post date:** [September 16, 2009, 8:22pm UTC](https://www.ruby-forum.com/t/import-utc-in-time/175624/2 "2009-09-16T20:22:19Z")

</div>

At 2009-09-16 12:12PM, “Luca R.” wrote:

> this not works  
> Time.parse(a)

The ActiveSupport gem has a time zone class:

```
require 'active_support'

utc = Time.now.utc
# => Wed Sep 16 17:28:58 UTC 2009
utc.class
# => Time

zone = ActiveSupport::TimeZone['Eastern Time (US & Canada)']

eastern = zone.at(utc.to_f)
# => Wed, 16 Sep 2009 13:28:58 EDT -04:00
eastern.class
# => ActiveSupport::TimeWithZone
```

---

<div class="post-metadata">

**Author:** ![stratboy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/838e76/32.png) [@stratboy](https://www.ruby-forum.com/u/stratboy)\
**Post date:** [September 16, 2009, 9:58pm UTC](https://www.ruby-forum.com/t/import-utc-in-time/175624/3 "2009-09-16T21:58:19Z")

</div>

Hi,

Am Donnerstag, 17. Sep 2009, 01:12:30 +0900 schrieb Luca R.:

> this not works  
> Time.parse(a)

UTC is a time zone, not a format. You need to load “time.rb”.

t = Time.now  
str\_l = t.to\_s  
t.utc  
str\_u = t.to\_s

require “time”  
q = Time.parse str\_l  
puts q  
q = Time.parse str\_u  
puts q

Bertram
