Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An example of using date Command in Linux system

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "examples of the use of date commands in the Linux system". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "the use of date commands in the Linux system examples" it!

Date usage 1:

Format: date [OPTION]... [+ FORMAT]

FORMAT controls the output. Interpreted sequences are:

A literal

% a locale's abbreviated weekday name (e.g., Sun)

% A locale's full weekday name (e.g., Sunday)

% b locale's abbreviated month name (e.g., Jan)

% B locale's full month name (e.g., January)

% c locale's date and time (e.g., Thu Mar 3 23:05:25 2005)

% C century; like% Y, except omit last two digits (e.g.20)

% d day of month (e.g.01)

D date; same as m/%d/%y

E day of month, space padded; same as _ d

F full date; same as Y-%m-%d

G last two digits of year of ISO week number (see G)

G year of ISO week number (see V); normally useful only with V

H same as b

% H hour (00.23)

% I hour (01.. 12)

% j day of year (001.. 366)

% k hour, space padded (0.23); same as% _ H

L hour, space padded (1.. 12); same as% _ I

% m month (01.. 12)

% M minute (00.59)

% n a newline

% N nanoseconds (0000000.9999999999)

% p locale's equivalent of either AM or PM; blank if not known

P like p, but lower case

R locale's 12-hour clock time (e.g., 11:11:04 PM)

% R 24-hour hour and minute; same as% HRV% M

% s seconds since 1970-01-01 00:00:00 UTC

% s second (00.60)

% ta tab

T time; same as H:%M:%S

% u day of week (1.. 7); 1 is Monday

% U week number of year, with Sunday as first day of week (00.53)

% V ISO week number, with Monday as first day of week (01.. 53)

W day of week (0.6); 0 is Sunday

% W week number of year, with Monday as first day of week (00.53)

% x locale's date representation (e.g., 12-31-99)

% X locale's time representation (e.g., 23:13:48)

% y last two digits of year (00.99)

% Y year

% z + hhmm numeric time zone (e.g.,-0400)

%: Z + hh:mm numeric time zone (e.g.,-04:00)

%:: Z + hh:mm:ss numeric time zone (e.g.,-04:00:00)

%:: z numeric time zone with: to necessary precision (e.g.,-04, + 05:30)

% Z alphabetic time zone abbreviation (e.g., EDT)

By default, date pads numeric fields with zeroes. The following optional flags may follow `%':

-(hyphen) do not pad the field

_ (underscore) pad with spaces

0 (zero) pad with zeros

^ use upper case if possible

# use opposite case if possible

For example:

1. Year Month Day

The code is as follows:

$date +% Y%m%d

20150107

two。 On the day of the year, only the last two are retained.

The code is as follows:

~ $date +% y%m%d

150107

3. Hours, minutes, seconds

The code is as follows:

~ $date +% H%M%S

233045

4. Year, month, day, hour, minute and second

The code is as follows:

~ $date +% Y%m%d%H%M%S

20150107233145

At this point, I believe you have a deeper understanding of "the use of 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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report