Ruby的strftime
有没有没有前导零的月份格式?
我发现%e
得到的日期没有前导零,但没有任何月份的运气。
最终想要一个如下格式的日期:9/1/2010
发布于 2012-03-27 04:16:31
文档显示了许多用于配置数字格式的不同选项。除了%-d格式之外,您还可以使用这些标志来代替"-":
Flags:
- don't pad a numerical output.
_ use spaces for padding.
0 use zeros for padding.
^ upcase the result string.
# change case.
: use colons for %z.
发布于 2012-03-07 08:14:59
我遇到了类似的问题,并通过将strftime("%m")
转换为整数来修复它。
例如:
strftime("%m")+0 give the current month as integer 'without leading zero'
虽然不优雅,但却很简单。
https://stackoverflow.com/questions/3831145
复制相似问题