When using strftime @tzformat = "%F,%l:00 %p"
:
I want exactly one space between the comma and the hour. But %l
gives no space for 10, 11 and 12 whereas if I put “ %l”
I get two spaces for 0-9 (one from the padding and another from the space I add).
Month has no-padding option. I don’t see the same for hour.
What am I missing?
The - modifier removes padding. If you use %-l instead of %l it will not put a space at all, and you can manually add a space.
Time.now.strftime @tzformat = "%F, %-l:00 %p" #=> "2015-01-29, 8:00 PM"
(Time.now + 3600*2).strftime @tzformat = "%F, %-l:00 %p" #=> "2015-01-29, 10:00 PM"
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