In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Date
Displays the current date in the given format, or sets the system time.
The scope of this command: RedHat, RHEL, Ubuntu, CentOS, SUSE, openSUSE, Fedora.
1. Grammar
Date [options].
Date [+ format].
Date-u [parameter]
Parameter format [MMDDhhmm [[CC] YY] [.ss]], corresponding to (month, day, hour, minute, first two bits, second after year, second)
2. List of options and formats
Option
Description
-- help
Help information
-- version
Display command version information
-f |-- file=DATEFILE
Like "--date", each line of the file is set once
-d |-- date=STRING
Displays the time represented by the string, not the current time
-r |-- reference=FILE
Displays the last modification time of the file
-R |-- frc-2822
Output date and time in rfc-2822
-- rfc-3339=TIMESPEC
Output date and time as rfc-3339, with precision of date, seconds, ns, separated by a space
-s |-- set=STRING
Sets the time with the specified string
-u |-- utc,-- universal
Output or set universal time
Format
Description
% a
The abbreviation of the week name of the current locale (for example, day, for Sunday)
% A
The full week name of the current locale (e. G. Sunday)
% b
The abbreviation of the month name of the current locale (e. G. one, for January)
% B
The full name of the month of the current locale (e.g. January)
% c
Date and time of the current locale (e.g., Thursday, March 3, 2005, 23:05:25)
% C
Century; for example,% Y, usually omitting the last two digits of the current year (for example, 20)
% d
Monthly date (for example: 01)
% D
A monthly date; equal to% m/%d/%y
% e
Monthly date, adding a space equal to% _ d
% F
Full date format, equivalent to% Y-%m-%d
% g
The last two digits of the ISO week year
% G
Number of weeks in ISO year
% H
Hours (00-23)
% I
Hours (00-12)
% j
Annualized date (001-366)
% k
Hours, 00: 23.
% l
Hour, 1: 12
% m
Month (01-12)
% M
Score (00-59)
% n
A new line
% N
1/1000000000 seconds
% p
The "morning" or "afternoon" under the current locale. The output is empty when unknown.
% P
Same as "% p", but outputs lowercase letters
% r
Current 12-hour clock time under locale (e.g. 11:11:04 afternoon)
% R
Hours and minutes of 24-hour time, equivalent to% Hpurs% M.
% s
The number of seconds from 00:00:00 on 1970-01-01
% S
Seconds (00-60)
% t
Tab character
% T
Time, equal to% H:%M:%S
% u
One day of the week, 1 is Monday. (1 / 7)
% U
The week ordinal of the year, with Sunday as the first day of each week (00-53)
% V
The week ordinal of the year under the ISO-8601 format specification, with Monday as the first day of each week (01-53)
% w
One day of the week, 0 is Sunday. (056)
% W
% x
Description of the date under the current locale (e.g. 12-31-99)
% X
Description of the time under the current locale (e.g. 23:13:48)
% y
The last two digits of the year (00-99)
% Y
Year
% z
+ hhmm format numeric time zone, such as "- 0400"
%: Z
+ hh:mm format numeric time zone, such as "- 04:00"
%:: Z
+ numeric time zone in hh:mm:ss format, such as "- 04:00:00"
%:: Z
Numeric time zone, use ":" to achieve the necessary precision, for example, "- 04, + 05:30"
% Z
Abbreviation for time zone, such as EDT
3. Description
By default, the number 0 is used to fill gaps in digital time. Of course, you can also specify other ways: "% -", do not fill; "% _", fill in spaces; "% 0", use 0; "% ^" use uppercase letters; "% #", use the opposite letter
"--date=String" is a free format and is a date string that is easy to read, such as "Sun, 16:21:42-0800 on February 29th" or "2004-02-29 16 21 42", or even "next Thursday". The date string may contain items indicating calendar date, time, time zone, midweek day, relative time, relative date, and number. An empty string represents the beginning of the day. The date string can contain items that indicate the calendar date, time, time zone, day of the week, relative time, relative date, and number. The date string format is more complex than what is easy to record here, but it is fully described in the info documentation.
4. Examples
1) do not apply any parameters, directly display the date and time
[root@localhost ~] # date
Wednesday, September 05, 2018, 11:48:58 CST / / Note, here is the CST time
2) display UTC time
[root@localhost] # date-u
Wednesday, September 05, 2018, 03:51:53 UTC
3) set CST date and time
[root@localhost ~] # date-s 2018-9-4 / / you can see the supported date formats here. If the time is not set, the default is a point.
Tuesday, September 04, 2018, 00:00:00 CST
[root@localhost ~] # date-s 20180905
Wednesday, September 05, 2018, 00:00:00 CST
[root@localhost] # date-s 2018-9-6
Thursday, September 06, 2018, 00:00:00 CST
[root@localhost ~] # date-s 11:56 / / modification time
Wednesday, September 05, 2018, 11:56:00 CST
[root@localhost ~] # date-s 11:54:40
Wednesday, September 05, 2018, 11:54:40 CST
4) shows the week and day of the year
[root@localhost ~] # date + day% j of week% U
Week 35, day 248.
5) display the time under the 12-hour system
[root@localhost ~] # date +% r
12:02:48
[root@localhost ~] # date +% p%H:%M:%S / / multiple format combinations can be used here to achieve the above effect
12:03:24
6) display the current date
[root@localhost ~] # date +% x
September 05, 2018
[root@localhost ~] # date +% F
2018-09-05
[root@localhost ~] # date +% Y-%m-%d / / Multiformat stitching
2018-09-05
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.