名称
date - 打印或设置系统日期和时间
总览
date [选项]... [+格式]
date [选项] [MMDDhhmm[[CC]YY][.ss]]
描述
根据指定格式显示当前时间或设置系统时间.
- -d, --date=STRING
- 显示由 STRING 指定的时间, 而不是当前时间
- -f, --file=DATEFILE
- 显示 DATEFILE 中每一行指定的时间, 如同将 DATEFILE 中的每行作为 --date 的参数一样
- -I, --iso-8601[=TIMESPEC] 按照 ISO-8601 的日期/时间格式输出时间.
- TIMESPEC=`date' (或者不指定时)仅输出日期,等于 `hours', `minutes', 或`seconds' 时按照指定精度输出日期及时间.
- -r, --reference=FILE
- 显示 FILE 的***修改时间
- -R, --rfc-822
- 根据 RFC-822 指定格式输出日期
- -s, --set=STRING
- 根据 STRING 设置时间
- -u, --utc, --universal
- 显示或设置全球时间(格林威治时间)
- --help
- 显示本帮助文件并退出
- --version
- 显示版本信息并退出
格式 FORMAT 控制着输出格式. 仅当选项指定为全球时间时本格式才有效。分别解释如下:
- %%
- 文本的 %
- %a
- 当前区域的星期几的简写 (Sun..Sat)
- %A
- 当前区域的星期几的全称 (不同长度) (Sunday..Saturday)
- %b
- 当前区域的月份的简写 (Jan..Dec)
- %B
- 当前区域的月份的全称(变长) (January..December)
- %c
- 当前区域的日期和时间 (Sat Nov 04 12:02:33 EST 1989)
- %d
- (月份中的)几号(用两位表示) (01..31)
- %D
- 日期(按照 月/日期/年 格式显示) (mm/dd/yy)
- %e
- (月份中的)几号(去零表示) ( 1..31)
- %h
- 同 %b
- %H
- 小时(按 24 小时制显示,用两位表示) (00..23)
- %I
- 小时(按 12 小时制显示,用两位表示) (01..12)
- %j
- (一年中的)第几天(用三位表示) (001..366)
- %k
- 小时(按 24 小时制显示,去零显示) ( 0..23)
- %l
- 小时(按 12 小时制显示,去零表示) ( 1..12)
- %m
- 月份(用两位表示) (01..12)
- %M
- 分钟数(用两位表示) (00..59)
- %n
- 换行
- %p
- 当前时间是上午 AM 还是下午 PM
- %r
- 时间,按 12 小时制显示 (hh:mm:ss [A/P]M)
- %s
- 从 1970年1月1日0点0分0秒到现在历经的秒数 (GNU扩充)
- %S
- 秒数(用两位表示)(00..60)
- %t
- 水平方向的 tab 制表符
- %T
- 时间,按 24 小时制显示(hh:mm:ss)
- %U
- (一年中的)第几个星期,以星期天作为一周的开始(用两位表示) (00..53)
- %V
- (一年中的)第几个星期,以星期一作为一周的开始(用两位表示) (01..52)
- %w
- 用数字表示星期几 (0..6); 0 代表星期天
- %W
- (一年中的)第几个星期,以星期一作为一周的开始(用两位表示) (00..53)
- %x
- 按照 (mm/dd/yy) 格式显示当前日期
- %X
- 按照 (%H:%M:%S) 格式显示当前时间
- %y
- 年的后两位数字 (00..99)
- %Y
- 年(用 4 位表示) (1970...)
- %z
- 按照 RFC-822 中指定的数字时区显示(如, -0500) (为非标准扩充)
- %Z
- 时区(例如, EDT (美国东部时区)), 如果不能决定是哪个时区则为空
默认情况下,用 0 填充数据的空缺部分. GNU 的 date 命令能分辨在 `%'和数字指示之间的以下修改.
- `-' (连接号) 不进行填充 `_' (下划线) 用空格进行填充
BUG报告
请向<bug-sh-utils@gnu.org>报告BUG.
参考
关于 date 的详细说明是个 Texinfo 手册. 如果在你的计算机上已经成功安装了 info 和 date 程序,你可以使用
- info date
命令访问完全手册.
版权
Copyright � 1999 Free Software Foundation, Inc.
翻译
本手册页由 liguoping 翻译
#p#
NAME
date - print or set the system date and time
SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
DESCRIPTION
Display the current time in the given FORMAT, or set the system date.
- -d, --date=STRING
- display time described by STRING, not `now'
- -f, --file=DATEFILE
- like --date once for each line of DATEFILE
- -ITIMESPEC, --iso-8601[=TIMESPEC]
- output date/time in ISO 8601 format. TIMESPEC=`date' for date only, `hours', `minutes', or `seconds' for date and time to the indicated precision. --iso-8601 without TIMESPEC defaults to `date'.
- -r, --reference=FILE
- display the last modification time of FILE
- -R, --rfc-2822
- output RFC-2822 compliant date string
- -s, --set=STRING
- set time described by STRING
- -u, --utc, --universal
- print or set Coordinated Universal Time
- --help
- display this help and exit
- --version
- output version information and exit
FORMAT controls the output. The only valid option for the second form specifies Coordinated Universal Time. Interpreted sequences are:
- %%
- a literal %
- %a
- locale's abbreviated weekday name (Sun..Sat)
- %A
- locale's full weekday name, variable length (Sunday..Saturday)
- %b
- locale's abbreviated month name (Jan..Dec)
- %B
- locale's full month name, variable length (January..December)
- %c
- locale's date and time (Sat Nov 04 12:02:33 EST 1989)
- %C
- century (year divided by 100 and truncated to an integer) [00-99]
- %d
- day of month (01..31)
- %D
- date (mm/dd/yy)
- %e
- day of month, blank padded ( 1..31)
- %F
- same as %Y-%m-%d
- %g
- the 2-digit year corresponding to the %V week number
- %G
- the 4-digit year corresponding to the %V week number
- %h
- same as %b
- %H
- hour (00..23)
- %I
- hour (01..12)
- %j
- day of year (001..366)
- %k
- hour ( 0..23)
- %l
- hour ( 1..12)
- %m
- month (01..12)
- %M
- minute (00..59)
- %n
- a newline
- %N
- nanoseconds (000000000..999999999)
- %p
- locale's upper case AM or PM indicator (blank in many locales)
- %P
- locale's lower case am or pm indicator (blank in many locales)
- %r
- time, 12-hour (hh:mm:ss [AP]M)
- %R
- time, 24-hour (hh:mm)
- %s
- seconds since `00:00:00 1970-01-01 UTC' (a GNU extension)
- %S
- second (00..60); the 60 is necessary to accommodate a leap second
- %t
- a horizontal tab
- %T
- time, 24-hour (hh:mm:ss)
- %u
- day of week (1..7); 1 represents Monday
- %U
- week number of year with Sunday as first day of week (00..53)
- %V
- week number of year with Monday as first day of week (01..53)
- %w
- day of week (0..6); 0 represents Sunday
- %W
- week number of year with Monday as first day of week (00..53)
- %x
- locale's date representation (mm/dd/yy)
- %X
- locale's time representation (%H:%M:%S)
- %y
- last two digits of year (00..99)
- %Y
- year (1970...)
- %z
- RFC-2822 style numeric timezone (-0500) (a nonstandard extension)
- %Z
- time zone (e.g., EDT), or nothing if no time zone is determinable
By default, date pads numeric fields with zeroes. GNU date recognizes the following modifiers between `%' and a numeric directive.
- `-' (hyphen) do not pad the field `_' (underscore) pad the field with spaces
ENVIRONMENT
- TZ
- Specifies the timezone, unless overridden by command line parameters. If neither is specified, the setting from /etc/localtime is used.
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
Report bugs to <bug-coreutils@gnu.org>.
COPYRIGHT
Copyright © 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
SEE ALSO
The full documentation for date is maintained as a Texinfo manual. If the info and date programs are properly installed at your site, the command
- info coreutils date
should give you access to the complete manual.