linux date-a,linux下 date的用法

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..60); the 60 is necessary to accommodate a leap sec-

ond其中60需要考虑到闰秒

%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

20090813112124

echo "`date \"+%Y-%m-%d %H:%M:%S\"`"

2009-08-17 11:35:48

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值