当前位置:网站首页>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进行辅助验证
- A high-quality WordPress download site template theme developed abroad
- 对象缓存服务的思考和实现
- 22年8月推广大使额外奖励规则
- [QNX Hypervisor 2.2 User Manual]9.14 set
- Golang must know the Go Mod command
- @JsonFormat(pattern=“yyyy-MM-dd“)时间差问题
- 硬件设备计算存储及数据交互杂谈
- 程序进程和线程(线程的并发与并行)以及线程的基本创建和使用
- EntityFramework保存到SQLServer 小数精度丢失
猜你喜欢

Judging decimal points and rounding of decimal operations in Golang

Audio alignment using cross-correlation

Recognize anomalies (you will understand after reading this)

(26)Blender源码分析之顶层菜单的关于菜单

Google Earth Engine——Error: Image.clipToBoundsAndScale, argument ‘input‘: Invalid type的错误解决

Handwritten a simple web server (B/S architecture)

【读书笔记->数据分析】02 数据分析准备

Shell common scripts: Nexus batch upload local warehouse enhanced version script (strongly recommended)

二叉树非递归遍历

面试突击69:TCP 可靠吗?为什么?
随机推荐
编写方法将一个数组扁平化并且去重和递增排序
Learn about C# anonymous methods
SQL injection Less38 (stack injection)
(26) About menu of the top menu of Blender source code analysis
[QNX Hypervisor 2.2 User Manual]9.14 set
Network security - crack WiFi through handshake packets (detailed tutorial)
【ACM】2022.7.31训练赛
日常--Kali开启SSH(详细教程)
"APIO2010" Patrol Problem Solution
SQL injection Less47 (error injection) and Less49 (time blind injection)
编译型语言和解释型语言的区别
「SDOI2016」征途 题解
网络安全--通过握手包破解WiFi(详细教程)
22年8月推广大使额外奖励规则
Niuke.com brush questions (1)
助力数字政府建设,中科三方构建域名安全保障体系
Handwritten a simple web server (B/S architecture)
「SDOI2016」征途 题解
C程序设计-方法与实践(清华大学出版社)习题解析
基于RT1052 Aworks nanopb string 类型固定长度使用方式(二十七)