Linux date command
The date command is a commonly used command in Linux and is mainly used to display the current time of the local machine. As follows:
In my Linux operating system, the date command is implemented by default in the format of year, month, day, week, hour, minute, and second, and then the Central Standard Time of CST. However, you can also modify the display format, for example:
Where:
1. Year: + % Y indicates that the Year is printed in four digit format, while + % y indicates that the Year is printed in two digit format;
2. Month: + % m indicates the month;
3. Date: + % d indicates the date (day );
4. Hour: + % H indicates the hour;
5. Minute: + % M indicates minute;
6. Seconds: + % S indicates seconds;
7. Weeks: + % w indicates the week, 1-6 indicates the day from Monday to Saturday, 0 indicates the day of Sunday, and W indicates the full week of today. Therefore, the result is 1 or 13.
The application of the date command is far more than that, and there are similar applications, such:
1. Get the date before the day: date-d "-1 day" + % d
2. Get the time one hour ago: date-d "-1 hour" + % H
3. Get the time one minute ago: date-d "-1 min" + % M
4. Obtain the time before January 1, January: date-d "-1 month"
5. Obtain the time from a year ago: date-d "-1 year"
6. Obtain the time from a week ago: date-d "-1 week"