Import utc in Time

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

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs