Hi all I am trying to format a mysql datetime attribute in my view. I have tried strftime(%r) as well as strftime(''%I:%M:%p'') In neither of the cases do I get the AM/PM parts. Anyone have a clue/pointer? thanks Ivor --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Add %p to the format string to get AM/PM, i.e. Time.now.strftime("%p") yields either AM or PM :) Cheers, James On Nov 13, 2007 4:29 PM, Ivor Paul <ivorpaul-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi all > > I am trying to format a mysql datetime attribute in my view. > I have tried strftime(%r) as well as strftime(''%I:%M:%p'') > > In neither of the cases do I get the AM/PM parts. > > Anyone have a clue/pointer? > > thanks > Ivor > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Strange - I can see that it works in IRB, but its not working in my rails console. There must be something in legacy code that is overriding strftime. thanks anyway. Ivor On Nov 13, 2007 9:22 AM, James Brooks <whitet73-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Add %p to the format string to get AM/PM, i.e. > > Time.now.strftime("%p") yields either AM or PM :) > > Cheers, > James > > > > On Nov 13, 2007 4:29 PM, Ivor Paul < ivorpaul-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > > > > Hi all > > > > I am trying to format a mysql datetime attribute in my view. > > I have tried strftime(%r) as well as strftime(''%I:%M:%p'') > > > > In neither of the cases do I get the AM/PM parts. > > > > Anyone have a clue/pointer? > > > > thanks > > Ivor > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---