Im wondering if it is possible to turn a string with a month name such as: "July 20, 2008" directly into a date object using strptime. If this is not possible am I going to have to write my own function to do this? I was thinking I could have and array with all the months and shuffle through it to get the month number and then use that to create a date object. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Dave Lynam wrote:> Im wondering if it is possible to turn a string with a month name such > as: "July 20, 2008" directly into a date object using strptime. If > this is not possible am I going to have to write my own function to do > this? I was thinking I could have and array with all the months and > shuffle through it to get the month number and then use that to create > a date object.Date.strptime("July 20, 2008", "%b %d, %Y") -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Elad Meidar - Creopolis.com
2008-Jul-25 00:13 UTC
Re: using strptime to create a date object
Something like the chronic gem at http://chronic.rubyforge.org/ maybe? On Jul 25, 3:08 am, Jeremy Weiskotten <rails-mailing-l...@andreas- s.net> wrote:> Dave Lynam wrote: > > Im wondering if it is possible to turn a string with a month name such > > as: "July 20, 2008" directly into a date object using strptime. If > > this is not possible am I going to have to write my own function to do > > this? I was thinking I could have and array with all the months and > > shuffle through it to get the month number and then use that to create > > a date object. > > Date.strptime("July 20, 2008", "%b %d, %Y") > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---