Linux system Time

Source: Internet
Author: User

Command-line mode
Date: Displays the current time
Date +%s: Display timestamp

Date command:
The general format is: Date [options] display time format (start with +, followed by format)

Option parameters:
-d< string > Displays the date and time that the string refers to (the string must be quoted)
-s< string > Set date and Time based on string (string must be quoted)-----only root permission can
--help online Help
--version displaying version information

List of date format character strings:
%H: Hours (00..23)
%I: Hours (01..12)
%k: Hours (0..23)
%l: Hours (1..12)
%M: minutes (00..59)
%p: Show local AM or PM
%r: Direct Display time (12 hours, Format hh:mm:ss [ap]m)
%s: The number of seconds from January 1, 1970 00:00:00 UTC to the current date
%s: Seconds (00..61)
%T: Direct Display time (24-hour system) (HH:MM:SS)
%x: Format of the display time (%h:%m:%s)
%Z: Show Time zone
% A: Abbreviation for the day of the week (Sun. Sat)
% A: The full name of the day of the week (Sunday. Saturday)
%B: The month abbreviation (Jan. DEC)
%B: Month full name (January. December)
%c: Display date and time directly
%d: Day (01..31)
%d: direct display?? Period (MM/DD/YY)
%h: With%b
%j: The first day of the Year (001..366)
%m: Month (01..12)
%u: Week of the Year (00..53) (with Sunday as the day of the week)
%w: The day of the Week (0..6)
%W: The week of the Year (00..53) (in the case of Monday for the first few weeks)
%x: Show date directly (MM/DD/YY)
%y: Last two digits of the year (00.99)
%Y: Full year (0000..9999)

Several common combinations of parameters:
%Y: Full year (0000..9999)
%m: Month (01..12)%x,%d: Show date directly (MM/DD/YY)
%d: Day (01..31)

%H: Hours (00..23)
%M: Minutes (00..59)%T: Direct Display time (24-hour system)
%s: Seconds (00..61)%x: equivalent to%h:%m:%s

%c: Display date and time directly
Example:
[[Email protected] Desktop]# date +%y-%m-%d/%h:%m:%s
2018-03-30/09:29:53
[[Email protected] Desktop]# date +%x/%h:%m:%s
March 30, 2018/09:30:08
[[Email protected] Desktop]# date +%d/%h:%m:%s
03/30/18/09:35:48
[[Email protected] Desktop]# date +%x/%t
March 30, 2018/09:30:18
[[Email protected] Desktop]# date +%x/%x
March 30, 2018/09 30 minutes 26 seconds
[[Email protected] Desktop]# date +%c
March 30, 2018 Friday 09:38 37 seconds

The date command itself provides the addition and subtraction of dates

Date +%y%m%d//show current Month day
Date +%y%m%d--date= "+1 Day"//Display days later
Date +%y%m%d--date= "-1 days"//Displays the day before
Date +%y%m%d--date= "-1 month"//show dates on January
Date +%y%m%d--date= "+1 Month"//displays the dates for the next January
Date +%y%m%d--date= "-1 Year"//show dates for previous years
Date +%y%m%d--date= "+1 Year"//show dates for next

Example:
[[Email protected] Desktop]# date +%y%m%d
20180330
[[Email protected] Desktop]# date +%y%m%d--date= "+1 Day"
20180331
[[Email protected] Desktop]# date +%y%m%d--date= "-1 day"
20180329
[[Email protected] Desktop]# date +%y%m%d--date= "+1 Month"
20180430
[[Email protected] Desktop]# date +%y%m%d--date= "-1 month"
20180302
[[Email protected] Desktop]# date +%y%m%d--date= "+1 Year"
20190330
[[Email protected] Desktop]# date +%y%m%d--date= "-1 year"
20170330

Time stamp
Time, time stamp: Date +%s
Time stamp, time: Date +%y:%m:%d-d @1425384141

Example:
[[Email protected] Desktop]# date +%s
1522372436
[Email protected] Desktop]# date +%y-%m-%d/%h:%m:%s [email protected]
2018-03-30/09:13:56

Linux system Time

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.