tft每日頭條

 > 科技

 > linux界面更改時間

linux界面更改時間

科技 更新时间:2024-05-08 21:41:03

查看當前系統時間:

[root@ifx142 ~]# date

2020年 06月 24日 星期三 20:05:34 CST

linux界面更改時間(linux基礎---修改系統時間)1

修改當前系統時間:

[root@ifx142 ~]# date -s '2020-06-24 12:20:20'

2020年 06月 24日 星期三 12:20:20 CST

[root@ifx142 ~]# date

2020年 06月 24日 星期三 12:20:21 CST

獲取當前年份:

date %Y

獲取當前月份:

date %m

獲取當前日期:

date %d

獲取當前小時:

date %H

獲取當前分鐘:

date %M

獲取當前日期:

date %S

獲取前後n天的時間:

[root@ifx142 ~]# date %Y-%m-%d -d "-3 days"

2020-06-21

[root@ifx142 ~]# date %Y-%m-%d -d "3 days"

2020-06-27

[root@ifx142 ~]# date

2020年 06月 24日 星期三 12:26:53 CST

[root@ifx142 ~]# date %H:%M:%S -d "3 hours";date

15:29:21

2020年 06月 24日 星期三 12:29:21 CST

[root@ifx142 ~]# date %H:%M:%S -d "-3 hours";date

9:29:21

2020年 06月 24日 星期三 12:29:21 CST

上述命令的解釋:

date %H:%M:%S 其實是定義輸出結果的顯示格式

-d "-3 hours" 用來計算和當前時間的差值

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved