Linux-日期时间相关命令
获取当前时间 date
1 [root@VM_0_3_centos ~]# date 2 Mon Mar 18 19:13:33 CST 2019 3 [root@VM_0_3_centos ~]#
date相关选项;
1 [root@VM_0_3_centos ~]# date --help 2 Usage: date [OPTION]... [+FORMAT] 3 or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] 4 Display the current time in the given FORMAT, or set the system date. 5 6 -d, --date=STRING display time described by STRING, not `now' 7 -f, --file=DATEFILE like --date once for each line of DATEFILE 8 -r, --reference=FILE display the last modification time of FILE 9 -R, --rfc-2822 output date and time in RFC 2822 format. 10 Example: Mon, 07 Aug 2006 12:34:56 -0600 11 --rfc-3339=TIMESPEC output date and time in RFC 3339 format. 12 TIMESPEC=`date', `seconds', or `ns' for 13 date and time to the indicated precision. 14 Date and time components are separated by 15 a single space: 2006-08-07 12:34:56-06:00 16 -s, --set=STRING set time described by STRING 17 -u, --utc, --universal print or set Coordinated Universal Time 18 --help display this help and exit 19 --version output version information and exit
这是date在Linux系统中部分帮助信息显示的内容。其中%F%T%Y%m%d%H%M%S%s:是我们比较常用的,详细见下图所示
示例
1 [root@VM_0_3_centos ~]# date +%Y%m%d%H%M%S 2 20190319195335 3 [root@VM_0_3_centos ~]#