Linux records----A date using a preliminary record

Source: Internet
Author: User
Tags set time

The display and setting of the system time in Linux can be used with the date command.


If we enter date directly, we will display the following

>>datethu Jul 18:49:55 PDT 2015


It has many parameters, the following is just a few of the author parameters of personal records.


-S set time

Such as

>>date-s 2015-07-31 #这往往把时间设置为00:00:00fri Jul 00:00:00 PDT 2015
>> date-s 20150730Thu 00:00:00 PDT 2015
>>date-s 2015/07/31FRI Jul 00:00:00 PDT 2015

The above is the setting of several dates, the following is the setting of the time

>>date-s 12:34:22FRI Jul 12:34:22 PDT 2015


--date Show when the condition is met

Such as

>>date Fri Jul 12:39:02 PDT >>date--date= "-1 day" #得到前一天的时间 Thu Jul 12:37:13 PDT 2015
>> Date--date= "-2 month" #得到前两个月的时间 Sun 12:40:37 PDT 2015
>> Date--date= "-1 year" #得到前一年的时间 Thu Jul 12:41:53 PDT 2014

(the upper minus can also be a plus sign, then the time will go forward)



If it appears to be displayed as (Fri 12:44:56 PDT 2015), it is not a person's favorite, you can also use the following way to display the time format you want

Such as

>> Date "+%y-%m-%d%h:%m:%s" 2015-07-31 12:47:12

{

%Y year

%m Month (01-12)

%d days (01-31)

%H hours (00-23)

%M min (00-59)

%s seconds (00-59)

}


The above is only for personal use records, only for parameters!

Linux records----A date using a preliminary record

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.