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
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
Add %p to the format string to get AM/PM, i.e.
Time.now.strftime("%p") yields either AM or PM
Cheers,
James
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs