当前位置:网站首页>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]

边栏推荐
- 【FPGA教程案例43】图像案例3——通过verilog实现图像sobel边缘提取,通过MATLAB进行辅助验证
- Shell common scripts: Nexus batch upload local warehouse enhanced version script (strongly recommended)
- Input and output optimization
- 什么时候可以使用 PushGateway
- C# Rectangle基本用法和图片切割
- 面试突击69:TCP 可靠吗?为什么?
- Handwritten a simple web server (B/S architecture)
- IPD process terminology
- 如何减少软件设计和实现之间鸿沟
- uniapp小程序检查、提示更新
猜你喜欢

【Acwing】第62场周赛 题解

逐步手撕轮播图3(保姆级教程)

嵌入式开发没有激情了,正常吗?

《ArchSummit:时代的呐喊,技术人听得到》

In Golang go-redis cluster mode, new connections are constantly created, and the problem of decreased efficiency is solved

什么是客户画像管理?

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#

Document management and tools in the development process
SQL27 View user details of different age groups

Flink 1.13(八)CDC
随机推荐
消息队列存储消息数据的MySQL表格
How to import a Golang external package and use it?
基于单片机GSM的防火防盗系统的设计
LeetCode 第 304 场周赛
[QNX Hypervisor 2.2 User Manual]9.16 system
[QNX Hypervisor 2.2用户手册]9.16 system
lua入门案例实战1234定义函数与标准函数库功能
支付模块实现
如何减少软件设计和实现之间鸿沟
Daily--Kali opens SSH (detailed tutorial)
PHP三元(三目)运算符
【云驻共创】【HCSD大咖直播】亲授大厂面试秘诀
SQL injection Less46 (injection after order by + rand() Boolean blind injection)
The difference between /usr/local/bin and /usr/bin
Unity-LineRenderer显示一条线
SQL injection Less38 (stack injection)
Input and output optimization
10大主流3D建模技术
SQL27 View user details of different age groups
Drawing process of hand-drawn map of scenic spots