Detailed Date command

Source: Internet
Author: User

The date command displays or sets the system time and date


Grammar

date [options] [parameters]


Options

-D < string;: displays the time or date specified by the string. double quotation marks before and after strings

-S < string;: sets the time or date specified by the string. double quotation marks before and after strings


Parameters

%H: Hours, 24-hour (00-23)

%I: Hours, 12-hour (01-12)

%M: minutes (00-59)

%s: Seconds (00-59)

%p: Show AM or PM

%s: from January 1, 1970 00:00:00 to the number of seconds currently experienced

%F: Show Date (%y-%m-%d)

%Y: Display year (4 bits, e.g. 2016)

%y: Display year (2 for, for example 2016 16)

%m: Month

%d: Day

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

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


Practice

[[Email protected] ~]# Date July 17, 2016 Sunday 21:02:53 Cst[[email protected] ~]# date +%f2016-07-17[[email protected] ~]# Date + "%F%T" 2016-07-17 21:04:15


-D to specify day month, respectively. Same as below command format

[Email protected] ~]# date-d "-1 month" +%f #显示上一个月的日期2016 -06-17[[email protected] ~]# date-d "+1 month" +%f #显示下 One-month date 2016-08-17

-S sets the current time. (only root permissions can be set, other users can only view)

[Email protected] ~]# date-s 2016-07-16 #这样设置日期会将具体时间设置为00 -00-00[[email protected] ~]# date-s 16:10:30 #只设定具体时间 , the date will not move [[email protected] ~]# date-s "20150505 21:10:01" #设置全部时间





Detailed Date command

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.