How can I convert a string such as '2007-01-31 12:22:26' to a Time
object?
irb(main):001:0> require 'time'
=> true
irb(main):002:0> Time.parse('2007-01-31 12:22:26')
=> Wed Jan 31 12:22:26 EST 2007
···
On Thu, Feb 01, 2007 at 06:20:08AM +0900, Chris McMahon wrote:
How can I convert a string such as '2007-01-31 12:22:26' to a Time
object?
Yup! You want Time.parse: ri Time.parse
Ben
···
On Thu, Feb 01, 2007, Chris McMahon wrote:
How can I convert a string such as '2007-01-31 12:22:26' to a Time
object?
Chris McMahon wrote:
How can I convert a string such as '2007-01-31 12:22:26' to a Time
object?
Chronic can do that and a whole lot more (in case you need to)!
require 'chronic'
Chronic.parse('2007-01-31 12:22:26')
=> Wed Jan 31 12:22:26 -0800 2007
Chronic.parse('today at 12:22.26')
=> Wed Jan 31 12:22:26 -0800 2007
Tom
Look at http://whytheluckystiff.net/ruby/pickaxe/
... see Time.mktime
... first you should split(' ') ya string and then split the result, order da stuff and put it into mktime...
···
Am 31.01.2007 um 22:20 schrieb Chris McMahon:
How can I convert a string such as '2007-01-31 12:22:26' to a Time
object?
hi friends..i tring to scrape links using nokogiri gem..i using the
while loop,but the linkis not working properly to while loop the
condition is "status =404"..pls solve my problem
···
--
Posted via http://www.ruby-forum.com/.
the ruby-units gem also has a helper for this...
'2007-01-31 12:22:26'.to_time #=> Wed Jan 31 12:22:26 EST 2007
_Kevin
···
On Jan 31, 5:47 pm, Florian Aßmann <florian.assm...@email.de> wrote:
Look athttp://whytheluckystiff.net/ruby/pickaxe/
.. see Time.mktime
.. first you should split(' ') ya string and then split the result,
order da stuff and put it into mktime...Am 31.01.2007 um 22:20 schrieb Chris McMahon:
> How can I convert a string such as '2007-01-31 12:22:26' to a Time
> object?
You should use double equals in such a condition, e.g. `status ==
404`. Also, the library you're using to fetch web pages might not
store HTTP statuses as numbers; you might have to compare against the
string '404' instead.
···
On Wed, Apr 4, 2012 at 8:29 AM, naveen kumar <lists@ruby-forum.com> wrote:
hi friends..i tring to scrape links using nokogiri gem..i using the
while loop,but the linkis not working properly to while loop the
condition is "status =404"..pls solve my problem
Time. parse seems to do the trick too...
irb(main):003:0> Time.parse("2007-01-31 12:22:26")
=> Wed Jan 31 12:22:26 SAST 2007
···
On 01 Feb 2007, at 2:55 PM, _Kevin wrote:
On Jan 31, 5:47 pm, Florian Aßmann <florian.assm...@email.de> wrote:
Look athttp://whytheluckystiff.net/ruby/pickaxe/
.. see Time.mktime
.. first you should split(' ') ya string and then split the result,
order da stuff and put it into mktime...Am 31.01.2007 um 22:20 schrieb Chris McMahon:
How can I convert a string such as '2007-01-31 12:22:26' to a Time
object?the ruby-units gem also has a helper for this...
'2007-01-31 12:22:26'.to_time #=> Wed Jan 31 12:22:26 EST 2007
_Kevin