Linux date command

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.