Linux Date Command

Source: Internet
Author: User

The date command is a common command in Linux, and the main function is to display the current time of the machine. As follows:


In my Linux operating system, the date command is implemented by default in the format of month-day-week-hour, and then CST Central Standard Time. However, you can also modify the display format yourself, such as:

which

1, Year: +%y indicates that the year is printed in four-digit format, whereas +%y indicates that the year is printed in two-digit format;

2, Month: +%m the month;

3, Date: +%d represents the date (days);

4, When: +%h represents the hour;

5, minute: +%m means minutes;

6, seconds: +%s = seconds;

7, Week: +%w represents the week, 1-6 for Monday to Saturday, 0 for Sunday, W for today's first few full weeks, so the result is 1 or 13.


The application of the date command is much more than that, and there are applications such as the following:

1, get a day ago Date: date-d "-1 days" +%d

2, get an hour ago: date-d "1 hour" +%h

3, get a minute ago: date-d "1 min" +%m

4, get a month before the time: date-d "-1 month"

5, get a year ago time: date-d "-1 Years"

6, get a week ago Time: date-d "1 Week"

Linux Date Command

Related Article

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.