# RFC-822 dates into Ruby dates

**URL:** <https://www.ruby-forum.com/t/rfc-822-dates-into-ruby-dates/139908>\
**Category:** Ruby\
**Created:** [June 9, 2008, 12:15am UTC](https://www.ruby-forum.com/t/rfc-822-dates-into-ruby-dates/139908 "2008-06-09T00:15:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kellygreer1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/77aa72/32.png) [@kellygreer1](https://www.ruby-forum.com/u/kellygreer1)\
**Post date:** [June 9, 2008, 12:15am UTC](https://www.ruby-forum.com/t/rfc-822-dates-into-ruby-dates/139908/1 "2008-06-09T00:15:20Z")

</div>

Whats the right way in Ruby to pull these kind of dates apart into a  
Ruby Date?

Mon, 8 Aug 2005 16:25:00 GMT

I’m working on parsing several RSS feeds and storing the data in  
MySQL.

Thanks,  
Kelly Greer  
removed\_email\_address@domain.invalid  
change nospam into yahoo

---

<div class="post-metadata">

**Author:** ![kellygreer1](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/77aa72/32.png) [@kellygreer1](https://www.ruby-forum.com/u/kellygreer1)\
**Post date:** [June 9, 2008, 1:01am UTC](https://www.ruby-forum.com/t/rfc-822-dates-into-ruby-dates/139908/2 "2008-06-09T01:01:01Z")

</div>

On Jun 8, 6:12 pm, kellygreer1 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Whats the right way in Ruby to pull these kind of dates apart into a  
> Ruby Date?
> 
> Mon, 8 Aug 2005 16:25:00 GMT

Hi Kelly,

The DateTime class (in library ‘date’) can parse those strings.

====

require ‘date’  
d = DateTime.parse(“Mon, 8 Aug 2005 16:25:00 GMT”)  
puts d.year  
puts d.hour  
puts d.zone

# and so forth… _or_

puts d.strftime “%Y %H %Z”

====

Hope that helps,

Eric

====

[LearnRuby.com](http://LearnRuby.com) offers Rails & Ruby HANDS-ON public & ON-SITE  
workshops.  
Ruby Fundamentals Wkshp June 16-18 Ann Arbor, Mich.  
Ready for Rails R. Wkshp June 23-24 Ann Arbor, Mich.  
Ruby on Rails Wkshp June 25-27 Ann Arbor, Mich.  
Ruby Plus Rails Combo Wkshp June 23-27 Ann Arbor, Mich  
Please visit [http://LearnRuby.com](http://LearnRuby.com) for all the details.
