DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Parse The Time In Ruby

06.10.2010
| 4905 views |
  • submit to reddit
        
require 'time'

d1 = Time.parse("2010-06-10 16:03:25 +0100")
#=> 2010-06-10 16:03:25 +0100

d2 = Time.parse("2010 Jun 10 16:03:25")
#=> 2010-06-10 16:03:25 +0100

Resources:
 - <a href="http://ruby-doc.org/core/classes/Time.html#M000305">Class: Time</a> [ruby-doc.org]