centos 7.2 查看時間,精確到毫秒級別


[root@ ~]# date +'%x %X.%N'
2019年08月06日 11時25分13秒.193666438
[root@commonTest ~]# date --help
用法:date [選項]... [+格式]
 或:date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.

Mandatory arguments to long options are mandatory for short options too.
  -d, --date=STRING         display time described by STRING, not 'now'
  -f, --file=DATEFILE       like --date once for each line of DATEFILE
  -I[TIMESPEC], --iso-8601[=TIMESPEC]  output date/time in ISO 8601 format.
                            TIMESPEC='date' for date only (the default),
                            'hours', 'minutes', 'seconds', or 'ns' for date
                            and time to the indicated precision.
  -r, --reference=文件          顯示文件指定文件的最后修改時間
  -R, --rfc-2822                以RFC 2822格式輸出日期和時間
                                例如:2006年8月7日,星期一 12:34:56 -0600
      --rfc-3339=TIMESPEC   output date and time in RFC 3339 format.
                            TIMESPEC='date', 'seconds', or 'ns' for
                            date and time to the indicated precision.
                            Date and time components are separated by
                            a single space: 2006-08-07 12:34:56-06:00
  -s, --set=STRING          set time described by STRING
  -u, --utc, --universal    print or set Coordinated Universal Time (UTC)
      --help            顯示此幫助信息並退出
      --version         顯示版本信息並退出

給定的格式FORMAT 控制着輸出,解釋序列如下:

  %%    一個文字的 %
  %a    當前locale 的星期名縮寫(例如: 日,代表星期日)
  %A    當前locale 的星期名全稱 (如:星期日)
  %b    當前locale 的月名縮寫 (如:一,代表一月)
  %B    當前locale 的月名全稱 (如:一月)
  %c    當前locale 的日期和時間 (如:2005年3月3日 星期四 23:05:25)
  %C    世紀;比如 %Y,通常為省略當前年份的后兩位數字(例如:20)
  %d    按月計的日期(例如:01)
  %D    按月計的日期;等於%m/%d/%y
  %e    按月計的日期,添加空格,等於%_d
  %F    完整日期格式,等價於 %Y-%m-%d
  %g    ISO-8601 格式年份的最后兩位 (參見%G)
  %G    ISO-8601 格式年份 (參見%V),一般只和 %V 結合使用
  %h    等於%b
  %H    小時(00-23)
  %I    小時(00-12)
  %j    按年計的日期(001-366)
  %k   hour, space padded ( 0..23); same as %_H
  %l   hour, space padded ( 1..12); same as %_I
  %m   month (01..12)
  %M   minute (00..59)
  %n    換行
  %N    納秒(000000000-999999999)
  %p    當前locale 下的"上午"或者"下午",未知時輸出為空
  %P    與%p 類似,但是輸出小寫字母
  %r    當前locale 下的 12 小時時鍾時間 (如:11:11:04 下午)
  %R    24 小時時間的時和分,等價於 %H:%M
  %s    自UTC 時間 1970-01-01 00:00:00 以來所經過的秒數
  %S    秒(00-60)
  %t    輸出制表符 Tab
  %T    時間,等於%H:%M:%S
  %u    星期,1 代表星期一
  %U    一年中的第幾周,以周日為每星期第一天(00-53)
  %V    ISO-8601 格式規范下的一年中第幾周,以周一為每星期第一天(01-53)
  %w    一星期中的第幾日(0-6),0 代表周一
  %W    一年中的第幾周,以周一為每星期第一天(00-53)
  %x    當前locale 下的日期描述 (如:12/31/99)
  %X    當前locale 下的時間描述 (如:23:13:48)
  %y    年份最后兩位數位 (00-99)
  %Y    年份
  %z +hhmm              數字時區(例如,-0400)
  %:z +hh:mm            數字時區(例如,-04:00)
  %::z +hh:mm:ss        數字時區(例如,-04:00:00)
  %:::z                 數字時區帶有必要的精度 (例如,-04,+05:30)
  %Z                    按字母表排序的時區縮寫 (例如,EDT)

默認情況下,日期的數字區域以0 填充。
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

在任何標記之后還允許一個可選的域寬度指定,它是一個十進制數字。
作為一個可選的修飾聲明,它可以是E,在可能的情況下使用本地環境關聯的
表示方式;或者是O,在可能的情況下使用本地環境關聯的數字符號。

Examples:
Convert seconds since the epoch (1970-01-01 UTC) to a date
  $ date --date='@2147483647'

Show the time on the west coast of the US (use tzselect(1) to find TZ)
  $ TZ='America/Los_Angeles' date

Show the local time for 9AM next Friday on the west coast of the US
  $ date --date='TZ="America/Los_Angeles" 09:00 next Fri'

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
請向<http://translationproject.org/team/zh_CN.html> 報告date 的翻譯錯誤
要獲取完整文檔,請運行:info coreutils 'date invocation'

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM