PDA

View Full Version : Reverting date from Time.to_s (RUBY)



utsavgupta
March 22nd, 2010, 06:59 PM
I receive the dates from Twitter in the following format "Mon Mar 22 04:42:17 +0000 2010"

Now how can I create a time object from this string... ie Obj.year=2010, Obj.month=3... etc etc


Regards

Utsav Gupta

stylishpants
March 22nd, 2010, 10:58 PM
require 'time'

t = Time.parse("Mon Mar 22 04:42:17 +0000 2010")
puts t.year
puts t.month