I have the following:
@comment.created_at.strftime("%I:%M %p %b %d")
Which outputs: 10:32 AM Dec 19
I'd like to output a lowercase am, like: 10:32am Dec 19
Any ideas on how to do that with ruby/rails?
thanks
You need to convert your string into Date object. For that, use Date#strptime . You can use Date#strftime to convert the Date object into preferred format.
Try to use %P instead using %p
Use %P instead of %p. That'll work with ruby 1.9 but for 1.8 you'll need to use .sub(' AM ', ' am ').sub(' PM ', ' pm ')
or similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With