Linux Date Display set time command learning

Source: Internet
Author: User
Tags set time


The function of the date command is to display and set the system date and time

Command format:

Date [OPTION] ... [+format]

Date [-u|--utc|--universal] [MMDDHHMM[[CC]YY][.SS]]


-D STRING: Displays the date described by STRING

-S STRING: Setting the date described by STRING

%Y years (for example: 1970,2009, etc.)

The last two digits of the%y year (1988 is 88)

%m Month (01..12)

%d days of one months (01..31)

%H hours (00..23)

%I Hours (01..12)

%k hours (0..23)

%l hours (1..12)

%p Displays AM or PM

%m Score (00..59)

%s seconds (00..59)

%r time (Hh:mm:ss am or PM), 12 hours

%T time (24-hour) (HH:MM:SS)

%x display the format of the time (%h:%m:%s)

%x displays the format of the date (MM/DD/YY)

%d Date (MM/DD/YY)

%s The number of seconds since January 1, 1970 00:00:00 to the current experience

Commonly used in this, the rest of the direct search man is good ...


1, there is a special time this noon, 2009-08 07 12:34:56, the following format can be displayed 12/34/56/7/8/9 this format. Where "-" can ignore the first "0".

Date + '%i/%m/%s/%-d/%-m/%-y '

2, Set month day is 20090807, time is 00:00

Date-s 20090807

3, set time, do not change the date

Date-s 16:02:23

4, set the date and time

Date-s "20090807 16:02:23"

5, view 100 days and 5 hours before the specific time

Date-d "-1 day 5 Hour" + "%y-%m-%d%h:%m:%s"

6, view the time after 100 minutes

date-d "+100 min" + "%y-%m-%d%h:%m:%s"

7. Time Stamp Calculation

Date-d 20090528 +%s

8, restore time stamp

Date-d "1970-01-01 1243440000 sec GMT" + "%F%T"

9, using NTP protocol to update the system time online


Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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: and provide relevant evidence. A staff member will contact you within 5 working days.