Forum: Ruby split string into words

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
95e2092707d6ee9e7634e169f713cc38?d=identicon&s=25 Jade CKS (kc_123)
on 2014-07-18 02:00
Hi I am new to Ruby
I am trying to split a string.
Example I have string 2013-12-01T00:00:00+11:00 and I only want to get
the date
I've been looking at the split() method but not sure what the delimiter
will be in this case ?? Can someone please help me here. Thanks
D9ebdcb66f1583378e6f72155db507e2?d=identicon&s=25 Hans Mackowiak (hanmac)
on 2014-07-18 13:01
why not using the time parse functions?

require "time"
Time.parse("2013-12-01T00:00:00+11:00").to_date.to_s #=> "2013-12-01"
B078cb4f4fb473c7a54d1fc36d10c70e?d=identicon&s=25 Regis d'Aubarede (raubarede)
on 2014-07-18 15:08
Jade CKS wrote in post #1152740:
> Hi I am new to Ruby
> I am trying to split a string.
> Example I have string 2013-12-01T00:00:00+11:00 and I only want to get
> the date
> I've been looking at the split() method but not sure what the delimiter
> will be in this case ??

"2013-12-01T00:00:00+11:00".split('T')[0]
95e2092707d6ee9e7634e169f713cc38?d=identicon&s=25 Jade CKS (kc_123)
on 2014-07-21 00:47
Thank you Hans and Regis for your reply. I actually manage to get the
date using the slice() method
But I want to try the time parse function. Thanks for your help guys
This topic is locked and can not be replied to.