date 中文man頁面
名稱
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.