date 查看或设置日期时间

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"
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值