In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly explains "the tutorial of using date time and date command in Linux system". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Now let the editor take you to learn the tutorial on the use of date time and date commands in the Linux system.
The "date" command prints the current date and time using standard output, or you can set it in depth.
The code is as follows:
Root@tecmint:~# date
Fri May 17 14:13:29 IST 2013
The code is as follows:
Root@tecmint:~# date-- set='14 may 2013 13 57'
Mon May 13 13:57:00 IST 2013
Note: this command is useful in scripts, and time-and date-based scripts are more perfect. And change the date and time in the terminal to make you more professional! (of course you need root permission to operate this, because it is a change in the system as a whole)
Displays the current time or sets the system time according to the specified format.
-d,-- date=STRING
Displays the time specified by STRING instead of the current time
-f,-- file=DATEFILE
Displays the time specified for each line in the DATEFILE as if each line in the DATEFILE were used as a parameter to-- date
-I,-- iso-8601 [= TIMESPEC] outputs time in the date / time format of ISO-8601.
TIMESPEC= `date'(or not specified) only outputs the date. If it is equal to `date `minutes', or `seconds', it outputs the date and time according to the specified precision.
-r,-- reference=FILE
Displays the last modification time of the FILE
-R,-- rfc-822
Output date according to the format specified by RFC-822
-s-- set=STRING
Set the time according to STRING
-u,-- utc,-- universal
Displays or sets global time (Greenwich mean time)
-- help
Show this help file and exit
-- version
Display version information and exit
Format FORMAT controls the output format. This format is valid only if the selected item is specified as global time. The explanations are as follows:
%%
% of the text
% a
Abbreviation of the day of the week in the current area (Sun..Sat)
% A
The full name of the day of the week in the current area (different lengths) (Sunday..Saturday)
% b
Abbreviation of the month of the current area (Jan..Dec)
% B
The full name (variable length) of the month in the current region (January..December)
% c
Date and time of the current region (Sat Nov 04 12:02:33 EST 1989)
% d
What date (in the middle of the month) (expressed by two digits) (01. 31)
% D
Date (displayed in month / date / year format) (mm/dd/yy)
% e
What date (in the middle of the month) (zero removal) (1. 31)
% h
Same as% b
% H
Hours (displayed by 24-hour system, expressed by two digits) (00.23)
% I
Hours (displayed by 12-hour system, expressed by two digits) (01.. 12)
% j
The day (of the year) (represented by three digits) (001. 366)
% k
Hours (displayed by 24-hour system, zero-removed display) (0.23)
% l
Hours (according to the 12-hour system, zero is indicated) (1. 12)
% m
Month (expressed by two digits) (01. 12)
% M
Minutes (expressed in two digits) (00.59)
% n
New line
% p
Is the current time morning AM or afternoon PM
% r
Time, displayed according to the 12-hour clock (hh:mm:ss [A big P] M)
% s
Seconds elapsed since 00:00:00 on January 1, 1970 (GNU expansion)
% S
Seconds (expressed in two digits) (00.60)
% t
Horizontal tab tabs
% T
Time, displayed on a 24-hour basis (hh:mm:ss)
% U
The week ordinal (of the year), with Sunday as the beginning of the week (represented by two people) (00. 53)
% V
The week ordinal (of the year), with Monday as the beginning of the week (expressed by two) (01. 52)
% w
Use numbers to indicate the day of the week (0. 6); 0 represents Sunday
% W
The week ordinal (of the year), with Monday as the beginning of the week (expressed by two people) (00. 53)
% x
Displays the current date in (mm/dd/yy) format
% X
Displays the current time in (% H:%M:%S) format
% y
The last two digits of the year (00.99)
% Y
Year (represented by 4 digits) (1970.)
% z
Display according to the numeric time zone specified in RFC-822 (e.g.,-0500) (non-standard extension)
% Z
Time zone (for example, EDT), empty if you cannot decide which time zone it is
By default, the vacant part of the data is filled with 0. The date command of GNU can distinguish the following modifications between `% 'and numeric indication.
`-'(connection number) do not fill` _'(underscore) fill with spaces
Example 1
The code is as follows:
[root@localhost www] shows the date and time
Saturday, May 04, 2013, 14:35:33 CST
The code is as follows:
[root@localhost www] # date-s' 14RV 35RV 40' # setting time
Saturday, May 04, 2013, 14:35:40 CST
Example 2
The code is as follows:
[root@rudder ~] # date +% m%d%H%M%S
0819150511
The code is as follows:
[root@rudder ~] # date 0819150511
Fri Aug 19 15:05:00 EST 2011
Example 3
The code is as follows:
# date-s / / sets the current time. Only root permission can be set, and others can only be viewed.
# date-s 20061010 / / is set to 20061010, which sets the specific time to empty 00:00:00
# date-s 12:23:23 / / set the specific time and will not change the date
# date-s "12:12:23 2006-10-10" / / this sets the full time
Example 4
The code is as follows:
[root@localhost ~] # date-d "20150305" +% s # timestamp
1425484800
The code is as follows:
[root@localhost ~] # date-d '1970-01-01 UTC 1425484800 seconds' # timestamp time
Thursday, March 05, 2015 00:00:00 CST
At this point, I believe you have a deeper understanding of the "tutorial on the use of date time and date commands in the Linux system". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.