当前位置:网站首页>date命令
date命令
2022-07-31 23:23:00 【华为云】
时间相关的指令
date显示
语法:date 选项 格式
功能:用于显示时间,设置时间,完成时间与时间戳之间的相互转换等
用途
1.在显示方面,使用者可以设定欲显示的格式,格式设定为一个加号,后接数个标记,其中常用的标记列表如下
%H : 小时(00~23)
%M : 分钟(00…59)
%S : 秒(00…61)
%X : 相当于 %H:%M:%S
%d : 日 (01…31)
%m : 月份 (01…12)
%Y : 完整年份 (0000…9999)
%F : 相当于 %Y-%m-%d
用途2.在设定时间方面
date -s :设置当前时间,只有root权限才能设置,其他普通用户只能查看。
date -s 20080523 //将日期设置成20080523,这样会把具体时间设置成空00:00:00
date -s 01:01:01 //设置具体时间,不会对日期做更改
date -s “01:01:01 2008-05-23″ //这样可以同时设置日期和具体时间
date -s “01:01:01 20080523″ //这样可以同时设置日期和具体时间
date -s “2008-05-23 01:01:01″ //这样可以同时设置日期和具体时间
date -s “20080523 01:01:01″ //这样可以同时设置日期和具体时间
用途3.时间戳 完成时间与时间戳之间的相互转换
什么是时间戳: 当前时间和计算机起始时间(1970年1月1日)的差值,单位为秒
Unix时间戳(英文为Unix epoch, Unix time, POSIX time 或 Unix timestamp)是从1970年1月1日(UTC/GMT的午夜)开始所经过的秒数,不考虑闰秒。
1)时间->时间戳:date +%s
时间戳: 1970/01/01/00:00累计到现在的秒数,给程序看的
2)时间戳->时间:date [email protected]
边栏推荐
- 新产品如何进行网络推广?
- 内核对设备树的处理
- Pytest first experience
- 编写方法将一个数组扁平化并且去重和递增排序
- The article you worked so hard to write may not be your original
- The difference between adding or not adding the ref keyword when a variable of reference type is used as a parameter in a method call in C#
- C# Rectangle basic usage and picture cutting
- 对象缓存服务的思考和实现
- SQL注入 Less54(限制次数的SQL注入+union注入)
- [QNX Hypervisor 2.2 User Manual]9.16 system
猜你喜欢
The latest masterpiece!Alibaba just released the interview reference guide (Taishan version), I just brushed it for 29 days
Shell常用脚本:Nexus批量上传本地仓库脚本
【读书笔记->数据分析】02 数据分析准备
Daily--Kali opens SSH (detailed tutorial)
cobaltstrike
如何减少软件设计和实现之间鸿沟
Shell common scripts: Nexus batch upload local warehouse enhanced version script (strongly recommended)
Binary tree non-recursive traversal
高等代数_证明_任何矩阵都相似于一个上三角矩阵
二叉树非递归遍历
随机推荐
SQL injection Less46 (injection after order by + rand() Boolean blind injection)
SQL injection Less38 (stack injection)
Components of TypeScript
In Golang go-redis cluster mode, new connections are constantly created, and the problem of decreased efficiency is solved
登录业务实现(单点登录+微信扫码+短信服务)
面试突击69:TCP 可靠吗?为什么?
2022-07-31:给出一个有n个点,m条有向边的图, 你可以施展魔法,把有向边,变成无向边, 比如A到B的有向边,权重为7。施展魔法之后,A和B通过该边到达彼此的代价都是7。 求,允许施展一次魔法
【Acwing】The 62nd Weekly Game Solution
Unity-通过预制件和克隆方法动态实现各个UGUI下控件的创建和显示
hboot and recovery, boot.img, system.img
网易云信圈组上线实时互动频道,「破冰」弱关系社交
Network security - crack WiFi through handshake packets (detailed tutorial)
ICML2022 | 深入研究置换敏感的图神经网络
MLP神经网络,GRNN神经网络,SVM神经网络以及深度学习神经网络对比识别人体健康非健康数据
什么是客户画像管理?
一文概述:VPN的基本模型及业务类型
「SDOI2016」征途 题解
leetcode:126. 单词接龙 II
浏览器下载快捷方式到桌面(PWA)
@JsonFormat(pattern="yyyy-MM-dd") time difference problem