Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多面手linux date命令 #16

Open
lemonchann opened this issue Jul 12, 2020 · 0 comments
Open

多面手linux date命令 #16

lemonchann opened this issue Jul 12, 2020 · 0 comments

Comments

@lemonchann
Copy link
Owner

https://lemonchann.github.io/blog/linux_date/

今天给项目写了个脚本需要获取前一天的时间,本来先获取今天的然后减一下,如果是1号的话还要考虑大小月份挺复杂的,于是去查了一下手册date命令原生支持,喜出望外,今天就详细说说这个看起来不起眼的date命令。

使用Linux的同学应该对linux的date命令不会陌生,经常需要在命令行敲一下这个命令获取当前时间。然而这只是他的能力冰山一角。

[lemon@localhost ~]$ date
2020年 02月 12日 星期三 19:51:46 CST

常规操作

获取时间戳,1970年1月1日0点0分0秒到现在历经的秒数

[lemon@localhost ~]$ date +%s
1581508426

时间戳还原,把刚才的秒数还原成时间字符串

[lemon@localhost ~]$ date -d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant