如何将linux日期从2015年1月14日转换为2015年1月14日?

时间:2015-01-15 20:10:24

标签: linux shell date

如何将linux日期从2015年1月14日转换为2015年1月14日

我不希望%m

中的那个0

以下是我使用的命令:

DATE=$(date --date yesterday +%d-%m-%Y)

谢谢,

1 个答案:

答案 0 :(得分:5)

尝试:date --date yesterday +%d-%-m-%Y

阅读手册页:

   By default, date pads numeric fields with zeroes.  The following optional flags may follow ‘%’:

   -      (hyphen) do not pad the field

   _      (underscore) pad with spaces

   0      (zero) pad with zeros

   ^      use upper case if possible

   #      use opposite case if possible