1. date用来显示具体的日期和24进制的时间
[[email protected] ~]$ date Fri Jan 25 14:17:17 CST 2019 [[email protected] ~]$ date ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-25 14:17:25
2. 具体的显示昨天,或者一天之后,一天之前
[[email protected]]$ date -d ‘yesterday‘ ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-24 14:18:53 [[email protected]]$ date -d ‘1 days‘ ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-26 14:19:04 [[email protected]]$ date -d ‘+1 days‘ ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-26 14:19:13 [[email protected]]$ date -d ‘-1 days‘ ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-24 14:19:21 [[email protected]]$ date -d ‘tomorrow‘ ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-26 14:19:30
3. 具体的显示一小时之后,一分钟之前等等
[[email protected]]$ date -d ‘2 hours‘ ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-25 16:21:33 [[email protected]]$ date -d ‘-2 hours‘ ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-25 12:21:39 [[email protected]]$ date -d ‘-2 minutes‘ ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-25 14:19:52 [[email protected]]$ date -d ‘-2 minute‘ ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-25 14:19:58 [[email protected]]$ date -d ‘-2 hour 2 minute‘ ‘+%Y-%m-%d %H:%M:%S‘ 2019-01-25 12:24:08
原文地址:https://www.cnblogs.com/qianjinyan/p/10319430.html
时间: 2024-10-10 08:26:33