In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly shows you "there are several formats of Shell dates under Linux". The content is simple and clear. I hope it can help you solve your doubts. Let me lead you to study and learn this article "there are several formats of Shell dates under Linux".
In the Shell environment, our command to get time is date, but the format and content of the time and date from date may not be what we want, so we may need to format it.
The common time domains are as follows:
% Y year (for example, 1970, 2015, 2018, etc.)
% m month (01.. 12)
% d the day ordinal of a month (01.. 31)
% H hours (00.23)
% M points (00.59)
% s seconds (00.59)
Use the date command with no arguments to get the current time and date. The result is usually the time in the CST standard format.
[alvin@VM_0_16_centos ~] $date Sat Nov 3 22:01:57 CST 2018
To get a specific in a specific format, the command is: date + 'format',. Note that this is case-sensitive.
[alvin@VM_0_16_centos ~] $date +'% Ymuri% mmi% d' 2018-11-03 [alvin@VM_0_16_centos ~] $date +'% Y/%m/%d% H15% MRO% S' 22:08:14 on 2018-11-03
Get yesterday's date. You can add the-d option to the above command.
[alvin@VM_0_16_centos ~] $date-d 'yesterday' +'% Y/%m/%d% HV% MV% S' 2018-11-02 22:24:31 or [alvin@VM_0_16_centos ~] $date-d 'today-1 day' +'% YMY% MMI% d' 2018-11-04
Get an hour before the current time
[alvin@VM_0_16_centos ~] $date-d'today-1 hour' +'% Y% m% d% H' 2018110414 or [alvin@VM_0_16_centos ~] $date +'% Y-%m-%d% HV% MV% S'-d'- 1 hours' 2018-11-0414: 43:38
Gets the day before the specified date. This is actually asking for relative time. For example, the following asks for the date of the day before the National Day:
[alvin@VM_0_16_centos ~] $date-d' 20181001-1 day' +'% Y% m% d' 20180930
Convert a date to a timestamp:
[alvin@VM_0_16_centos ~] $date-d "Nov 4 15:49:41 CST 2018" +% s 1541317781
Convert the timestamp back to the date:
[alvin@VM_0_16_centos] $date-d @ 1541317781 Sun Nov 4 15:49:41 CST 2018
Convert the timestamp to a date and display it in a specific format:
[alvin@VM_0_16_centos ~] $date-d @ 1541317781 +'% Y%m%d% HVA% MVD% S' 20181104 above 15:49:41 is all the contents of this article entitled "there are several Shell date formats under Linux". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.