Hi, In one of my application i have to create a date obj like 2009-02-05 23:26:35 but for this i have following input which is integer. form_day = 05, from_month = 02 from_year= 2009 and from_time=12:00:00 Please suggest a best solution for it? -- 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 -~----------~----~----~----~------~----~------~--~---
Look up the date class in the prag prog''s book. It explains how to create dates. Date.new(2008,12,30) for example. Blog: http://random8.zenunit.com/ Learn rails: http://sensei.zenunit.com/ On 06/02/2009, at 8:42 PM, Sunny Bogawat <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org > wrote:> > Hi, > > In one of my application i have to create a date obj like 2009-02-05 > 23:26:35 > but for this i have following input which is integer. > form_day = 05, from_month = 02 from_year= 2009 and from_time=12:00:00 > > Please suggest a best solution for it? > -- > 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 -~----------~----~----~----~------~----~------~--~---
try it like this: date = DateTime.civil(y=from_year, m=from_month, d=from_month, min=from_time.min, s=from_time.sec, of=0) here is the according ruby-api: http://www.ruby-doc.org/core/classes/DateTime.html --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---