Thursday, February 19, 2009

Convert a String into Time

require'rubygems'
=> true
require'time'
=> true

a="Thu Feb 19 18:16:33 +0530 2009"
=> "Thu Feb 19 18:16:33 +0530 2009"
a=Time.parse(a)
=> Thu Feb 19 18:16:33 +0530 2009

a.day
=> 19
a.year
=> 2009
a.month
=> 2
a.hour
=> 18
a.min
=> 16
a.sec
=> 33


thanks..

No comments: