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

What is the use of Linux's date command

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

Share

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

This article mainly explains "what is the use of Linux's date command". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what is the use of Linux's date command"?

The Linux common command date command can be used to display or set the date and time of the system.

Syntax date [- u] [- d datestr] [--s datestr] [--utc] [--universal] [--date=datestr] [--set=datestr] [--help] [--version] [+ FORMAT] [MMDDhhmm [[CC] YY] [.ss] parameter-d datestr: display the time set in datestr (non-system time)-- help: display auxiliary message-s datestr: The system time is set to the time set in datestr-u: displays the current Greenwich mean time-version: displays the version number-d: displays the date and time indicated by the string. The string must be enclosed in double quotation marks;-s: sets the date and time according to the string. The string must be enclosed in double quotation marks; the date format string list% Y year (in four digits). % m month (expressed as 01-12). D date (expressed as 01-31). % H hours (expressed as 00-23). % M minutes (expressed as 00-59). % s seconds (expressed in local idioms). % s total seconds. The starting time is 1970-01-01 00:00:00 UTC. % I hours (expressed as 01-12). % K hours (expressed as 0-23). % l hours (expressed as 0-12). % P AM or PM. % r time (including minutes and seconds, hours are expressed as 12 hours AM/PM). % T time (including minutes and seconds, hours are expressed in a 24-hour system). % X time (expressed in local idioms). % Z downtown. Abbreviation for% a week. The full name of% A week. Abbreviation of% b month English name. The full English name of% B month. C date and time. Entering only the date instruction will show the same result. % D date (including year, month and day). % j Day ordinal of the year. % U number of weeks in the year. % w days of the week, 0 for Sunday, 1 for Monday, and so on. % x date (expressed in local idiom). % y year (expressed as 00-99). % n inserts a new row when displayed. % t inserts tab when displayed. MM month (necessary) DD date (necessary) hh hour (necessary) mm minute (necessary) ss second (optional) instance # yyyy-mm-dd format display date [oracle@xag182 test_tar] $date + "% Y-%m-%d" 2020-11-27 # yyyy-mm-dd hh34:mi:ss format display date [oracle@xag182 test_tar] $date + "% Y-%m-%d% HGV% Mazu% S "2020-11-27 15:15:19 # seconds [oracle@xag182 test_tar] $date-d" 2020-12-12 15:41:30 "+"% Y/%m/%d% H:%M:%S "2020-12-12 15:41:30 calculated time from 1970-01-01 00:00:00 UTC total seconds since [oracle@xag182 test_tar] $date +% s 1606464154 [oracle@xag182 Test_tar] $date +% s 1606464160 1 year ago [oracle@xag182 test_tar] $date + "% Y-%m-%d% H:%M:%S"-d "- 1 year" 2019-11-27 15:50:23 1 year after [oracle@xag182 test_tar] $date + "% Y-%m-%d% H:%M:%S"-d "+ 1 year" 2021-11-27 before 15:50:37 January [oracle@xag182 test] _ tar] $date + "% Y-%m-%d% H:%M:%S"-d "- 1 month" 2020-10-27 after 15:50:47 January [oracle@xag182 test_tar] $date + "% Y-%m-%d% H:%M:%S"-d "+ 1 month" 2020-12-27 15:50:56 1 day ago [oracle@xag182 test_tar] $date + "% Y-%m-%d% HVOR% Mazu% S "- d"-1 day "2020-11-26 15:51:12 1 hour [oracle@xag182 test_tar] $date +"% Y-%m-%d% H:%M:%S "- d"-1 hour "2020-11-27 14:51:21 30 minutes [oracle@xag182 test_tar] $date +"% Y-%m-%d% H:%M:%S "- d"-30 minute "2020-11 -27 15:21:37 120 minutes before [oracle@xag182 test_tar] $date + "% Y-%m-%d% H:%M:%S"-d "- 120 second" 2020-11-27 15:49:53 1 day and after 1 hour (i.e. after 25 hours) [oracle@xag182 test_tar] $date + "% Y-%m-%d% H:%M:%S"-d "+ 1 day + 1 hour" 2020-11-28 16: One day after 54:50 and before and after 23 hours [oracle@xag182 test_tar] $date + "% Y-%m-%d% H:%M:%S"-d "+ 1 day-1 hour" 2020-11-28 14:55:02 difference between [oracle@xag182 test_tar] $vault startling $(date +% s). [oracle@xag182 test_tar] $vendorendental $(date +% s) [oracle@xag182 test_tar] $vested v_start $((v_end-v_start)) [oracle@xag182 test_tar] $echo $v_difference 14 Thank you for reading. This is the content of "what is the use of Linux's date command". After the study of this article, I believe you have a deeper understanding of the use of Linux's date command. The specific use situation still needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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: 243

*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

Development

Wechat

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

12
Report