Linux 基本命令(一)--时间 常用命令
发布时间:2020-12-13 23:36:40 所属栏目:Linux 来源:网络整理
导读:2019-07-30 ? date 系统时间参数 显示时间是个常用的命令,在写shell脚本中也经常会用到与日期相关文件名或时间显示。无论是linux还是windows下都是date命令。 Linux下date命令用法 date [OPTION]… [+FORMAT] date [-u|--utc|--universal] [MMDDhhmm[[CC]YY
2019-07-30 ? date 系统时间参数 显示时间是个常用的命令,在写shell脚本中也经常会用到与日期相关文件名或时间显示。无论是linux还是windows下都是date命令。 Linux下date命令用法
date命令参数
date命令输出显示格式
上述格式不必全都记住,只需要掌握几个常用的即可。例如%Y表示年,%m表示月,%d表示日,%H表示小时,%M表示分钟,%S表示秒,%s表示从 1970 年 1 月 1 日 00:00:00 UTC 到目前为止的秒数,相当于time函数,%w表示一周中的第几天 自定义时间举例说明: [[email?protected] test]# date 2017年 10月 12日 星期四 03:40:41 CST [[email?protected] test]# date -I 2017-10-12 [[email?protected] test]# date -Ihours 2017-10-12T03+0800 [[email?protected] test]# date -Iminutes 2017-10-12T03:41+0800 [[email?protected] test]# date -Iseconds 2017-10-12T03:41:41+0800 [[email?protected] test]# date -R Thu,12 Oct 2017 03:42:12 +0800 [[email?protected] test]# date -u 2017年 10月 11日 星期三 19:42:19 UTC [[email?protected] test]# date +"Today is %A." Today is 星期四. [[email?protected] test]# date +"Date:%b. %e,%G" Date:10月. 12,2017 [[email?protected] test]# date +"Date: %b.%e,%G" Date: 10月.12,2017 [[email?protected] test]# date +"%x %X" 2017年10月12日 03时42分56秒 [[email?protected] test]# date +"%Y-%m-%d %H:%M:%S" 2017-10-12 03:43:07 [[email?protected] test]# date +"%Y-%m-%d %I:%M:%S %p" 2017-10-12 03:43:27 上午 [[email?protected] test]# 常用时间格式: [[email?protected] test]# date "+%Y-%m-%d %H:%M:%S" 2017-10-12 03:45:36 [[email?protected] test]# date "+%Y-%m-%d" 2017-10-12 [[email?protected] test]# Linux date 日期加减运算 [[email?protected] test]# date #正常时间 2017年 10月 12日 星期四 03:49:52 CST [[email?protected] test]# date +"%b %e,%G" #自定义时间格式 10月 12,2017 [[email?protected] test]# date +"%b %e,%G" -d‘-1 day‘ #时间减1天,加1天类似 10月 11,2017 [[email?protected] test]# date +"%b %e,%G" -d‘+1 month‘ #时间加一个月,减一个月类似 11月 12,2017 [[email?protected] test]# date +"%Y年%m月%d日" #自定义时间格式,年月日 2017年10月12日 [[email?protected] test]# date +"%Y年%m月%d日" -d‘-1 day‘ #同上面加减1天(或加减1月) 2017年10月11日 [[email?protected] test]# date +"%Y年%-m月%d日" #去除月份前的0,例如‘2017年08月12日’显示为‘2017年8月12日’ 2017年10月12日 [[email?protected] test]# date -d‘-1 day‘ +"%b %e,%G" #时间减1天,加1天类似 10月 11,2017 [[email?protected] test]# date -d‘+1 month‘ +"%b %e,%G" #时间加一个月,减一个月类似 11月 12,2017 ? 转自:https://www.cnblogs.com/weijiangbao/p/7675200.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- [LeetCode] Longest Mountain in Array 数组中最长的山
- linux – Java Swing – 当JFrame最大化时,鼠标指针在上下文
- LINUX学习:LVM逻辑卷管理
- redhat – SELinux:如何显示类型的所有允许规则?
- linux – 在命令行centos / fedora / ubuntu上记录所有内容
- linux中的gdb C代码 – 地址超出范围
- linux – iptables阻止客户端ip上网并保持局域网访问
- 用于MIPS和x86 arch的android mupdf
- 如何使用Linux机箱通过ssh隧道连接Windows远程桌面?
- 如果kill -9没有效果,如何在Linux中终止进程