linux中date命令示例,Linux战地日记—date命令详细示例

date命令详细示例

日期格式:年/月/日 和 月/日/年

[bestcoder@localhost chapter1]$ date +%F

2015-10-14

[bestcoder@localhost chapter1]$ date +%D

10/14/15

显示几天前/后,几年前/后

[bestcoder@localhost chapter1]$ date +%D -d '-3 days'

10/11/15

[bestcoder@localhost chapter1]$ date +%F -d '+3 days'

2015-10-17

[bestcoder@localhost chapter1]$ date +%F -d '-1 year'

2014-10-14

[bestcoder@localhost chapter1]$ date +%F -d '-3 year'

2012-10-14

显示时间,几小时前/后

[bestcoder@localhost chapter1]$ date +%T

08:04:07

[bestcoder@localhost chapter1]$ date +%T -d '3 hours'

11:05:43

[bestcoder@localhost chapter1]$ date +%T -d '-2 hours'

06:05:07

显示当前日期的时间戳

[bestcoder@localhost chapter1]$ date +%s

1444835173

根据时间戳显示时间

[bestcoder@localhost chapter1]$ date -d "@1444835173"

Wed Oct 14 08:06:13 PDT 2015

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值