Ruby strftime: Month without leading zero?

前端 未结 4 976
忘了有多久
忘了有多久 2021-01-30 15:57

Does Ruby\'s strftime have a format for the month without a leading zero?

I found %e for getting the day without the leading zero, but not hav

4条回答
  •  遇见更好的自我
    2021-01-30 16:04

    I had a similar problem and fixed it by converting strftime("%m") into an integer.

    For example:

    strftime("%m")+0 give the current month as integer 'without leading zero'
    

    Simple, though not elegant.

提交回复
热议问题