Linux date command

Source: Internet
Author: User
& Amp; 26684; formula: date [OPTION] [& amp; 43; FORMAT]-ddatestr,

FORMAT: date [OPTION]... [+ FORMAT]

-D datestr, -- date datestr displays the date described by datestr
-S datestr, -- set datestr to set the date described by datestr
-U, -- universal Display or set the universal time

By default, the date and time of the current system are displayed.

1. Format and display

You can set the format to be displayed. the format is set to a plus sign followed by several tags. the list of available tags is as follows: %: print %

% N: next row % t: hop % H: Hour (00 .. 23) % I: Hour (01 .. 12) % k: Hour (0 .. 23) % l: Hour (1 .. 12) % M: minute (00 .. 59) % p: local AM or PM % r: direct display time (in 12-hour format: hh: mm: ss [AP] M) % s: seconds from January 1, 1970 00:00:00 UTC till now % S: Seconds (00 .. 61) % T: direct display time (in 24-hour format) % X: equivalent to % H: % M: % S % Z: Display time zone % a: Day of the week (Sun .. sat) % A: The day of the week (Sunday .. saturday) % B: Month (Jan .. dec) % B: month (January .. december) % c: Display date and time % d: Day (01 .. 31) % D: Display date (mm/dd/yy) % h: same as % B % j: Day of the year (001 .. 366) % m: Month (01 .. 12) % U: Week (00 .. 53) (Sunday is the first day of a week) % w: The day of a week (0 .. 6) % W: Week (00 .. 53) (Monday is the first day of a week) % x: displays the date (mm/dd/yy) % y: The last two digits of the year (00.99) % Y: full year (0000 .. 9999)
2. set the time
Date-s // set the current time. only the root permission can be set. others can only be viewed. Date-s 20080523 // Set to 20080523, so that the specific time is set to null 00: 00: 00 date-s 01:01:01 // set the specific time, do not change the date-s "01:01:01" // you can set the full time date-s "01:01:01 20080523" // you can set the full time date-s "01:01:01 ″ // you can set the full time date-s "20080523 01:01:01" // you can set the full time
3. add or subtract (display specific time)
Date + % Y % m % d // display current day Year Month day date + % Y % m % d-d "+ 1 day" // Display date + % Y of the next day % m % d-d "-1 day" // display the date of the previous day + % Y % m % d-d "-1 month" // display the date of the previous month + % Y % m % d-d "+ 1 month" // display the date of the next month, January + % Y % m % d-d "-1 year" // display the previous date of the year + % Y % m % d-d "+ 1 year" // display the date of the next year
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.