bash - Bash 命令日期的 -d 选项格式

标签 bash date

date的手册页中:

-d, --date=STRING         display time described by STRING, not 'now'

听起来您应该输入准确的日期,但我发现 date -d "-1 day" 有效。

我只想要一个 date 命令的 -d option 格式列表。我用谷歌搜索,但没有找到。

最佳答案

man date:

DATE STRING

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.

然后您可以获得更多信息和示例输入

info date

您可以在 Date input formats 中找到.

A date is a string, possibly empty, containing many items separated by whitespace. The whitespace may be omitted when no ambiguity arises. The empty string means the beginning of today (i.e., midnight). Order of the items is immaterial. A date string may contain many flavors of items:

  • calendar date items
  • time of day items
  • time zone items
  • combined date and time of day items
  • day of the week items
  • relative items
  • pure numbers.

关于bash - Bash 命令日期的 -d 选项格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22450302/

相关文章:

bash - 与退出状态的比较不起作用

javascript - JS 日期对象解析不正确

database - 我的 Oracle 10gr2 检查约束有什么问题?试图强制执行日期范围

linux bash 数组在 while block 后不包含任何数据

c++ - 运行我的程序说 "bash: ./program Permission denied"

linux - “read”命令不在“while read line”循环中执行

mysql - 按星期几和一天中的时间过滤日期

c++ - Qt 和 mkpasswd MD5 hashes 区别

Javascript 更新时间函数导致高 CPU

php - Laravel Carbon 错误,日期相差年份