歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> UNIX date命令簡介

UNIX date命令簡介

日期:2017/2/28 14:52:56   编辑:Linux教程

date 命令
參數含義:
%a :顯示星期簡寫 (Sun..Sat)
%A :顯示完整星期(Sunday..Saturday)
%b :顯示月份簡寫(Jan..Dec)
%B :顯示完整月份(January..December)
%c :顯示當前日期,格式如:Thu Aug 13 11:04:05 2009
%C :顯示世紀,當前年除100後的整數部分,如當前為20 (year divided by 100 and truncated to an integer)[00-99]
%d :顯示當前那日 ,范圍(01..31)
%D :日期,格式如(mm/dd/yy)
%e :顯示當前日,與%d不同的是%d顯示01,而%e顯示1,范圍 ( 1..31)
%F :如 %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 :與 %b相同
%H :24小時制的小時,范圍(00..23)
%I :12小時制的小時,范圍(01..12)
%j :一年中的那天,范圍是(001..366)
%k :24小時制的小時,只顯示1而不顯示01,范圍( 0..23)
%l :12小時制的小時,只顯示1而不顯示01,范圍( 1..12)
%m :顯示月份,范圍(01..12)
%M :顯示分鐘,范圍(00..59)
%n :新行
%N :顯示秒(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 :時間, 12小時制,格式(hh:mm:ss [AP]M)
%R :時間, 24小時制,格式(hh:mm)
%s :從1970-01-01 00:00:00到現在的秒數。seconds since '00:00:00 1970-01-01 UTC' (a GNU extension)
%S :秒,顯示當前時間的秒,范圍(00..59);  Displays the seconds as a decimal number (00- 59).
%t :a horizontal tab
%T :時間, 24-hour (hh:mm:ss)24小時制
%u :day of week (1..7); 1 represents Monday,星期幾,其中1代表星期一,其他類似。
%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,星期幾,其中0代表星期日,1代表星期一,其他類似
%W :week number of year with Monday as first day of week (00..53),一年中的第幾個星期,其中星期一為第一天,范圍從00-53
%x :locale's date representation (mm/dd/yy) 按mm/dd/yy格式顯示日期
%X :locale's time representation (%H:%M:%S)等於%H:%M:%S
%y :last two digits of year (00..99)顯示2位數的年
%Y :year (1970...) 顯示4位數的年
%z :RFC-2822 style numeric timezone (-0500) (a nonstandard extension)
%Z :time zone (e.g., EDT), or nothing if no time zone is determinable

例子:
date +%Y-%m-%d-%k:%M:%S
2012-12-24-21:21:33

echo "`date \"+%Y-%m-%d %H:%M:%S\"`"
2012-12-24 21:21:46

Copyright © Linux教程網 All Rights Reserved