日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > linux >内容正文

linux

linux:date 命令

發(fā)布時(shí)間:2024/9/19 linux 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 linux:date 命令 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

前言

  • linux

date 命令

date命令可以用來顯示或設(shè)定系統(tǒng)的日期與時(shí)間。

常用日期格式定義

> date +"%Y-%m-%d"
2019-09-20
> date +"%Y-%m-%d %H:%M:%S"
2019-09-20 15:59:14
> date -d "1970-01-01 1234567890 seconds" +"%Y-%m-%d %H:%m:%s"
2009-02-13 23:02:1234539090
> date +"%Y%m%d%H%M%S"
20190920155945

參數(shù)解釋

-d <字符串>:顯示字符串所指的日期與時(shí)間。字符串前后必須加上雙引號(hào);
-s <字符串>:根據(jù)字符串來設(shè)置日期與時(shí)間。字符串前后必須加上雙引號(hào);
-u:顯示GMT;
–help:在線幫助;
–version:顯示版本信息。

日期格式符號(hào)含義

%H 小時(shí)(以00-23來表示)。 %I 小時(shí)(以01-12來表示)。 %K 小時(shí)(以0-23來表示)。 %l 小時(shí)(以0-12來表示)。 %M 分鐘(以00-59來表示)。 %P AM或PM。 %r 時(shí)間(含時(shí)分秒,小時(shí)以12小時(shí)AM/PM來表示)。 %s 總秒數(shù)。起算時(shí)間為1970-01-01 00:00:00 UTC。 %S 秒(以本地的慣用法來表示)。 %T 時(shí)間(含時(shí)分秒,小時(shí)以24小時(shí)制來表示)。 %X 時(shí)間(以本地的慣用法來表示)。 %Z 市區(qū)。 %a 星期的縮寫。 %A 星期的完整名稱。 %b 月份英文名的縮寫。 %B 月份的完整英文名稱。 %c 日期與時(shí)間。只輸入date指令也會(huì)顯示同樣的結(jié)果。 %d 日期(以01-31來表示)。 %D 日期(含年月日)。 %j 該年中的第幾天。 %m 月份(以01-12來表示)。 %U 該年中的周數(shù)。 %w 該周的天數(shù),0代表周日,1代表周一,異詞類推。 %x 日期(以本地的慣用法來表示)。 %y 年份(以00-99來表示)。 %Y 年份(以四位數(shù)來表示)。 %n 在顯示時(shí),插入新的一行。 %t 在顯示時(shí),插入tab。

幫助信息

Usage: date [OPTION]... [+FORMAT]or: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] Display the current time in the given FORMAT, or set the system date.Mandatory arguments to long options are mandatory for short options too.-d, --date=STRING display time described by STRING, not 'now'-f, --file=DATEFILE like --date once for each line of DATEFILE-I[TIMESPEC], --iso-8601[=TIMESPEC] output date/time in ISO 8601 format.TIMESPEC='date' for date only (the default),'hours', 'minutes', 'seconds', or 'ns' for dateand time to the indicated precision.-r, --reference=FILE display the last modification time of FILE-R, --rfc-2822 output date and time in RFC 2822 format.Example: Mon, 07 Aug 2006 12:34:56 -0600--rfc-3339=TIMESPEC output date and time in RFC 3339 format.TIMESPEC='date', 'seconds', or 'ns' fordate and time to the indicated precision.Date and time components are separated bya single space: 2006-08-07 12:34:56-06:00-s, --set=STRING set time described by STRING-u, --utc, --universal print or set Coordinated Universal Time (UTC)--help display this help and exit--version output version information and exitFORMAT 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 (000000000..999999999)%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 %H:%M%s seconds since 1970-01-01 00:00:00 UTC%S second (00..60)%t a 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 spaces0 (zero) pad with zeros^ use upper case if possible# use opposite case if possibleAfter any flags comes an optional field width, as a decimal number; then an optional modifier, which is either E to use the locale's alternate representations if available, or O to use the locale's alternate numeric symbols if available.Examples: Convert seconds since the epoch (1970-01-01 UTC) to a date$ date --date='@2147483647'Show the time on the west coast of the US (use tzselect(1) to find TZ)$ TZ='America/Los_Angeles' dateShow the local time for 9AM next Friday on the west coast of the US$ date --date='TZ="America/Los_Angeles" 09:00 next Fri'GNU coreutils online help: <http://www.gnu.org/software/coreutils/> For complete documentation, run: info coreutils 'date invocation'

總結(jié)

以上是生活随笔為你收集整理的linux:date 命令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。