Shell command: Date

Source: Internet
Author: User

I. Introduction to the DATE command

Function: Used to display time, this command is used much in the shell script
Format: Date + parameter + format
Parameter:-D to display the specified time

Date    Show current time April 13, 2016 Wed 14:33:55 CST
date-s "2016-10-12 07:09:35"    Manual modification Time Wednesday, October 12, 2016 07:09:35 CST

Automatic proofreading Time:

Yum install–y NTP           ntpdate time.windows.com     ntpdate ntp.fudan.edu.cn     (optional) proofread Fudan's time server

Second, date format

%F: Month Day (full date)
%T: Hours and seconds (time)
%Y: Year (show four-bit) (years)
%y: Year (show two-bit) (years)
%m: Month (mouth)
%d: Day (date)
%H: When (hour)
%M: Min (minute)
%s: Seconds (second)
%s: Seconds (timestamp, which indicates how many seconds have passed from 1970.1.1 to now)
%w: Zhou (week)
%W: Week (week of the year, 52 weeks a year)

[Email protected] ~]#Date +%fShow date 2016-10-12[[email protected] ~]#Date +%tDisplay time division seconds 07:19:56[[email Protected] ~]#Date +%yDisplay year (four digits) 2016[[email protected] ~]#Date +%mShow month 10[[email protected] ~]#Date + "%y-%m-%d%h:%m:%s"Displays the custom time 2016-10-12 07:25:36[[email protected] ~]#DateShow current time October 12, 2016 Wed 07:29:48 Cst[[email protected] ~]#date-d "-2 days" +%fShowing two days ago 2016-10-10[[email protected] ~]#date-d "-2 month" +%fShow time two months ago 2016-08-12[[email protected] ~]#date-d "-2 hour" +%tShowing two hours ago 05:30:39[[email protected] ~]#date-d "-2 min" +%tShowing two minutes ago 07:28:49[[email protected] ~]#date-d "-2 sec" +%tShowing two seconds ago 07:30:52

Shell command: Date

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.