date (1) - print or set the system date and time
Usage: date [OPTION]... [+FORMAT]
or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
-d, --date=STRING display time described by STRING, not 'now'
-s, --set=STRING set time described by STRING
常用的格式化的控制符
%% a literal %
%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)
年月日时分秒——————数字格式
可自定义的组合
%y last two digits of year (00..99)
%Y year (full four digits of year,like 2021)
%m month (01..12) (不显示零,可以使用下划线来填充空位!比如:%_m)
%d day of month (e.g., 01) (can use underscore like `%_d`)
%H hour (00..23) (can use underscore like `%_H`)
%I hour (01..12) (can use underscore like `%_I`)
%M minute (00..59) (can use underscore like `%_M`)
%S second (00..60) (can use underscore like `%_S`)
预定义的日期时间格式
%D date; same as %m/%d/%y
%F full date; same as %Y-%m-%d
%r locale's 12-hour clock time (e.g., 11:11:04 PM)
%R 24-hour hour and minute; same as %H:%M
%T time; same as %H:%M:%S
日期时间的部分字段的英文显示
月份
%b locale's abbreviated month name (e.g., Jan)
%B locale's full month name (e.g., January)
星期
%a locale's abbreviated weekday name (e.g., Sun)
%A locale's full weekday name (e.g., Sunday)
上下午
%p locale's equivalent of either AM or PM; blank if not known
%P like %p, but lower case
日期时间的部分预定义计算
%j day of year (001..366)
%U week number of year, with Sunday as first day of week (00..53)
%W week number of year, with Monday as first day of week (00..53)
%u day of week (1..7); 1 is Monday
%w day of week (0..6); 0 is Sunday
支持的特殊含义的符号
- (hyphen) do not pad the field
_ (underscore) pad with spaces
0 (zero) pad with zeros
^ use upper case if possible
# use opposite case if possible
[root@OS7 ~]# date
[root@OS7 ~]# date +%c
[root@OS7 ~]# date "+%Y-%m-%d %H:%M:%S %p"
[root@OS7 ~]# date "+%a %Y-%m-%d %H:%M:%S %p"
date 查看或设置日期时间
最新推荐文章于 2024-08-02 23:04:43 发布