Ruby strftime: Month without leading zero?

Some versions of strftime do allow prefixing with minus to format out leading zeros, for eg:

strftime "%-d/%-m/%y"

However this will depend on strftime on your system. So for consistency I would do something like this instead:

dt = Time.local(2010, 'Sep', 1)
printf "%d/%d/%d", dt.day, dt.month, dt.year

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)