[root@hf-01 ~]# date
2018年 01月 14日 星期日 06:13:14 CST
[root@hf-01 ~]#
[root@hf-01 ~]# LANG=en 切换为英文显示
[root@hf-01 ~]# date
Sun Jan 14 06:19:49 CST 2018
[root@hf-01 ~]# date +%Y
2018 四位的年
[root@hf-01 ~]# date +%y
18 两位的年
[root@hf-01 ~]# date +%m
01 月份
[root@hf-01 ~]# date +%M
20 分钟
[root@hf-01 ~]# date +%d
14 日期
[root@hf-01 ~]# date +%D
01/14/18 直接标记年月日,不过格式比较特殊
[root@hf-01 ~]# date +%Y%m%d
20180114 年月日
[root@hf-01 ~]# date +%F
2018-01-14 年月日,这种带横杠的
[root@hf-01 ~]#
[root@hf-01 ~]# date +%w
0 表示周几
[root@hf-01 ~]# date +%W
02 今年的第几周,今年的第二周
[root@hf-01 ~]# date +%h
Jan 英文的月份
[root@hf-01 ~]# date +%H
06 小时
[root@hf-01 ~]# date +%S
04 秒
[root@hf-01 ~]# date +%s
1515882702 这是一个时间戳,距离1970总共过去多少秒
[root@hf-01 ~]# date +%T
06:24:36
[root@hf-01 ~]# date +%H:%M:%S
06:24:36
[root@hf-01 ~]#
[root@hf-01 ~]# cal
January 2018
Su Mo Tu We Th Fr Sa
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31
[root@hf-01 ~]#
[root@hf-01 ~]# date -d "-1 day"
Sat Jan 13 06:47:30 CST 2018
[root@hf-01 ~]# date -d "-1 day" +%F
2018-01-13
[root@hf-01 ~]# date -d "+1 month" +%F
2018-02-14
[root@hf-01 ~]# date -d "+1 year" +%F
2019-01-14
[root@hf-01 ~]# date -d "+1 hour" +%T
08:09:05
[root@hf-01 ~]# date -d "+1 min" +%T
07:11:21
[root@hf-01 ~]# date +%s
1515885248
[root@hf-01 ~]# date -d @1515885248
Sun Jan 14 07:14:08 CST 2018
[root@hf-01 ~]#
[root@hf-01 ~]# date +%s -d "2018-01-13 07:14:08"
1515798848
[root@hf-01 ~]# date -d @1515798848
Sat Jan 13 07:14:08 CST 2018
[root@hf-01 ~]#