这里是man date
页说,大约为选项格式是什么:
The --date=STRING is a mostly free format human readable date string such as
"Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next
Thursday". A date string may contain items indicating calendar date, time of day,
time zone, day of week, relative time, relative date, and numbers. An empty
string indicates the beginning of the day. The date string format is more
complex than is easily documented here but is fully described in the info
documentation.
因此,你可以使用,例如:
date --date "2014-06-12 09:03 UTC" --utc +%d.%m.%Y,\ %H:%M\ UTC
# Output: 12.06.2014, 09:03 UTC
得到你的愿望。
你可以从你的第一输出很容易得到这一第二种形式与sed
线如下:
sed 's/\([0-9]\{2\}\)\.\([0-9]\{2\}\)\.\([0-9]\{4\}\), \(.*\)/\3-\2-\1 \4/'
<<< '12.06.2014, 09:03 UTC'
# Output: 2014-06-12 09:03 UTC
注意,它可能会更快地输出日期在ISO 8601的格式在第一时间进行再利用,例如与:
date --utc +%F\ %H:%M\ UTC
# Output: 2014-06-12 10:12 UTC
只需删除逗号,并用斜线替换点:'日期-utc +%d /%m /%Y \%H:%M \ UTC'。 – fedorqui
您可以在'bsd date'中指定自定义日期格式,但不能在'gnu'中。 – BroSlow