Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将linux日期从2015年1月14日转换为2015年1月14日?_Linux_Shell_Date - Fatal编程技术网

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

如何将linux日期从2015年1月14日转换为2015年1月14日?,linux,shell,date,Linux,Shell,Date,如何将linux日期从2015年1月14日转换为2015年1月14日 我不希望%m中出现0 下面是我正在使用的命令: DATE=$(date --date yesterday +%d-%m-%Y) 谢谢,试试:日期--昨天的日期+%d-%m-%Y 阅读手册页: By default, date pads numeric fields with zeroes. The following optional flags may follow ‘%’: - (hyphen)

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

我不希望%m中出现0

下面是我正在使用的命令:

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

试试:
日期--昨天的日期+%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

强烈建议您将日期输出为
%Y-%m-%d
——该格式(ISO标准)在时间和词汇上排序相同。np:)如果您觉得有用,请接受答案。谢谢。如果您不想在当月使用前导零,您可能也不想在当天使用前导零:
+%-d-%-m-%Y
。但我支持glenn jackman的建议,即使用ISO 8610标准格式
+%Y-%m-%d
,除非您有特定的理由不这样做。