Help with time

If i have a date time like this “2013-04-01T12:01:03-07:00”

how can i get a Time object in Ruby 2 without UTC added. i mean get
“2013-04-01 12:01:03”

On 05/15/2013 04:43 PM, ricardo l. wrote:

If i have a date time like this “2013-04-01T12:01:03-07:00”

how can i get a Time object in Ruby 2 without UTC added. i mean get
“2013-04-01 12:01:03”

require ‘time’
=> true

Time.parse(“2013-04-01T12:01:03-07:00”.split(’-’)[0…-2].join(’-’))
=> 2013-04-01 12:01:03 0200

hth
ralf

thank you, but i wanna know there is no way to get that with functions
of Time, for example if i do
Time.parse(“2013-04-01T12:01:03-07:00”).utc.strftime(’%Y-%m-%d %T’) i
get “2013-04-01 19:01:03”

On Wed, May 15, 2013 at 7:43 AM, ricardo l. [email protected]
wrote:

If i have a date time like this “2013-04-01T12:01:03-07:00”

how can i get a Time object in Ruby 2 without UTC added. i mean get
“2013-04-01 12:01:03”

2.0.0 (main):0 > my_datetime = DateTime.now
=> #<DateTime: 2013-05-15T08:00:03-07:00
(106117695001519021/43200000000,-7/24,2299161)>
2.0.0 (main):0 > my_datetime.to_time.strftime("%F %H:%m:%S")
=> “2013-05-15 08:05:03”

Note that this only “hides” the UTC offset. If you use this new Time
object for comparisons, that’s still relevant.

On 05/15/2013 05:11 PM, ricardo l. wrote:

if i do Time.parse(“2013-04-01T12:01:03-07:00”).to_time.strftime("%F
%H:%m:%S") i get 2013-04-01 14:04:03 and i want 2013-04-01 12:01:03

what about the getlocal methods? it return time objects without utc (
http://www.ruby-doc.org/core-2.0/Time.html#method-i-getlocal)

if i do Time.parse(“2013-04-01T12:01:03-07:00”).to_time.strftime("%F
%H:%m:%S") i get 2013-04-01 14:04:03 and i want 2013-04-01 12:01:03

thank you, im gonna read that, cause im a noob in ruby :stuck_out_tongue: .