Parameters of the date command of Linux system and methods of obtaining time stamp

Source: Internet
Author: User

Date instruction Related Usage example

Date usage: date [OPTION] ... [+format]
Date [-u|--utc|--universal] [MMDDHHMM[[CC]YY][.SS]]

Enter Date directly

Date specified format display time: Date +%y_%m_%d, date +%y:%m:%d

Date can be used to display or set the system's datetime and time.
1. In the display aspect, the user can set the format to be displayed, the format is set to a plus sign followed by a number of tags, where the list of available tags is as follows:
%n: Next line

%t: Jump Grid

%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)

%x: Equivalent to%h:%m:%s
%Z: Show time zone%a: Day of the Week (Sun. Sat)
%A: Day of the Week (Sunday). Saturday)
%b: Month (Jan). DEC)
%B: Month (January). December)
%c: Direct display period and time
%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)

2. In terms of setting time
Date-s//Set current time, only root privileges can be set, others can only be viewed. Date-s 20100101//set to 20100101, this will set the specific time
Empty 00:00:00
Date-s 01:01:01//Set specific time, do not change the date period
Date-s "01:01:01 2010-01-01″//so you can set the whole time
Date-s "01:01:01 20100101″//so you can set the whole time

The 3.date command itself provides a date plus and minus operation

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

Time stamp
Time, time stamp: Date +%s
Time stamp, time: Date +%y:%m:%d-d @1425384141
The Unix timestamp (in English for Unix epoch, Unix time, posixme, or Unix timestamp) is the number of seconds since January 1, 1970 (Midnight of Utc/gmt), regardless of the leap seconds.



Parameters of the date command of Linux system and methods of obtaining time stamp

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.