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

Display the date and time using the date command of linux

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

What the editor shares with you today is to use the date command of linux to display the date and time. I believe many people do not know much about it. In order to make you understand better, I have summarized the following contents for you. Let's look down together. I'm sure you'll get something.

The date command can be used to display or set the date and time of the system. In terms of display, users can set the format they want to display. The format is set to a plus sign followed by several marks.

If you do not start with a plus sign, you want to set the time, but the time format is MMDDhhmm [[CC] YY] [.ss], where MM is the month, DD is the day, hh is the hour, mm is the minute, CC is the first two digits of the year, YY is the last two digits of the year, and ss is the number of seconds.

Syntax format: date [options] [+ output form]

Common parameters:

-d datestr displays the time set in datestr (non-system time)-s datestr sets the system time to the time set in datestr-u displays the current Greenwich mean time-help displays help-- version displays the version number

Reference example

Show the current time:

[root@linuxcool ~] # date

3 April 12 14:08:12 CST 2019

[root@linuxcool ~] # date'+% c'

Wednesday, April 17, 2019, 14:09:02

Output in your own format:

[root@linuxcool ~] # date'+ usr_time: $1V% M% P-hey'

Usr_time: $1:16 p.m.-hey

Jump the line after the time is displayed, and then display the current date:

[root@linuxcool ~] # date'+% T% n% D'

The number of months and days actually displayed:

[root@linuxcool ~] # date'+% B% d'

Display date and set time (12:34:56):

[root@linuxcool ~] # date-- date'12 date 34date 56' about using the date command of linux to display the date and time is shared here. I hope the above content can have some reference value for everyone and can be applied. If you like this article, you might as well share it for more people to see.

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