使用法: date [オプション]... [+フォーマット]
もしくは: date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
Display the current time in the given FORMAT, or set the system date.
-d, --date=STRING display time described by STRING, not `now'
-f, --file=DATEFILE like --date once for each line of DATEFILE
-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' for
date and time to the indicated precision.
Date and time components are separated by
a 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
--help この使い方を表示して終了
--version バージョン情報を表示して終了
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 %b と同じ
%H 時 (00〜23)
%I 時 (01〜12)
%j 年日付 (001〜366)
%k 時 ( 0〜23)
%l 時 ( 1〜12)
%m 月 (01〜12)
%M 分 (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 timezone (e.g., -0400)
%:z +hh:mm numeric timezone (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
After 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.
Report date bugs to bug-coreutils@gnu.org
GNU coreutils home page:
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.
-d, --date=STRING display time described by STRING, not `now'
-f, --file=DATEFILE like --date once for each line of DATEFILE
-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' for
date and time to the indicated precision.
Date and time components are separated by
a 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
--help display this help and exit
--version output version information and exit
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 ( 0..23)
%l hour ( 1..12)
%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 timezone (e.g., -0400)
%:z +hh:mm numeric timezone (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
After 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.
Report date bugs to bug-coreutils@gnu.org
GNU coreutils home page:
date(1) date(1)
名前
date - システムの日付と時刻を表示・設定する
書式
date [-uR] [-d datestr] [-f datefile] [-r file] [-s datestr] [-I [time-
spec]] [--date=datestr] [--file=datefile] [--iso-8601[=timespec]]
[--reference=file] [--set=datestr] [--rfc-822] [--universal] [--utc]
[+format] [MMDDhhmm[[CC]YY][.ss]]
date [--help] [--version]
説明
date は引数を指定しないと、現在の時刻と日付を表示する (表示形式 は ‘%a
%b %e %H:%M:%S %Z %Y’ となる。以下を参照のこと)。
引数が指定され、かつその先頭が ‘+’ で始まっておらず、かつ実行者が適切な
権限を持っていれば、 date はシステムの時計を引数で指定された時刻・日 付
に設定する。 --date および --set の両オプションは、このような引数と一緒
に用いることはできない。 --universal オプションをこのような引数とともに
用 いると、指定した時刻・日付が (地方時ではなく) 協定世界時のものになる
。引数には数字だけを用いることができ、それぞれ以下の意味を持つ:
MM 月
DD 日 (月内通算)
hh 時
mm 分
CC 年の最初の 2 桁 (省略可)
YY 年の最後の 2 桁 (省略可)
ss 秒 (省略可)
指定された引数が ‘+’ で始まる場合には、 date は現在の時刻と日付を表示す
る (あるいは --date オプションで指定された時刻と日付を指定する)。表示形
式はこの引数によって制御され、引数の書式は strftime(3) 関数にわたす文字
列の書式と同じである。 `%’ で始まるフィールドを除き、 format 文字列中の
文字はそのまま変更されずに表示される。
時刻フィールド
%H 時 (00..23)
%I 時 (01..12)
%k 時 (0..23)
%l 時 (1..12)
%M 分 (00..59)
%n 改行
%N ナノ秒 (000000000..999999999)
%p AM あるいは PM のロケールでの表示。不明な場合は空白
%r 時刻、12 時間 (hh:mm:ss [AP]M)
%s 1970-01-01 00:00:00 UTC からの秒数 (標準外の拡張)
%S 秒 (00..60)
%T 時刻、24 時間 (hh:mm:ss)
%X ロケールによる時刻の表現 (%H:%M:%S)
%Z タイムゾーン (例 EDT)、あるいはタイムゾーンが決定できないなら ば
無し
日付フィールド
%a ロケールの省略形の曜日名 (Sun..Sat)
%A ロケールの完全表記の曜日名、可変長 (Sunday..Saturday)
%b ロケールの省略形の月名 (Jan..Dec)
%B ロケールの完全表記の月名、可変長 (January..December)
%c ロケールの日付と時刻 (Sat Nov 04 12:02:33 EST 1989)
%d 月内通算日数 (01..31)
%D 日付 (mm/dd/yy)
%h %b と同じ
%j 年内通算日数 (001..366)
%m 月 (01..12)
%U 日曜日を週の最初の日とした年内通算週 (00..53)
%w 週のうちの曜日 (0..6) (0 が日曜日)
%W 月曜日を週の最初の日とした年内通算週 (00..53)
%x ロケールの日付表現 (mm/dd/yy)
%y 年の最後の 2 つの数字 (00..99)
%Y 年 (1970...)
文字フィールド
%% 文字 %
%n 改行
%t 水平タブ
文字埋め (padding)
デフォルトでは、 date は数値のフィールドを 0 で埋める。したがって、例え
ば数値表示の月は常に 2 桁で出力される。 GNU は date の機能を拡張して お
り、以下の非標準の数値修正子を ‘%’ とフィールドの間に置くことができる:
- ( ハイフン) フィールドを埋めない。出力が人に読まれる場合には便利
である。
_ (アンダースコア) フィールドをスペースで埋める。出力に決まった 数
の文字が必要だが、0 を使いたくない場合に便利である。
オプション
-d datestr, --date datestr
現 在の時刻・日付の代わりに、 datestr で指定された時刻・日付を表
示する。 datestr は普通のフォーマットならだいたいなんでも使う こ
とができる。月名、タイムゾーン、‘am’ や ‘pm’ なども用いてよい。
-f datefile, --file=datefile
-d とともに指定された datefile を 1 行ずつパースして、結果の時刻
と日付を表示する。 datefile が ‘-’ の場合は標準入力が用いられ る
。これは、たくさんの日付を処理しなければならない場合に便利である
。 date の実行ファイルを何回も起動するオーバーヘッドは無視できな
いからである。
-r file, --reference=file
表示する時刻と日付を file の最終修正時刻にする。
-s datestr, --set datestr
時 刻と日付を datestr に設定する。上述の -d を見よ。成功すると 0
を返し、失敗すると 0 以外を返す。
-u, --universal, --utc
タイムゾーンが地方時 (壁時計の時刻) ではなく UTC0 (協定世界時 、
こ れはグリニッジ平均時もしくは GMT として知られている) に設定さ
れたものとする。
-I [timespec], --iso-8601[=timespec]
日付を ISO 8601 で指定されている書式 ‘%Y-%m-%d’ で、時刻を time-
spec で指定されている形式で表示する (後者のデフォルトは auto)。
時刻部分の表示には ‘T’ が前置され、‘%z’ (--utc が指定されてい る
場合には ‘%Z’) が後置される。
auto 時刻を表示しない。
hours その日の時刻を表示する。
minutes
時・分を表示する。
seconds
時・分・秒を表示する。
-R, --rfc-822
時 刻 と 日 付 を RFC-822 で指定された書式である ‘%a, %_d %b %Y
%H:%M:%S %z’ で表示する。 --utc が同時に指定されると、‘%z’ の 代
わりに ‘GMT’ を用いる。日付と月の名前は ‘C’ ロケールに基づいて表
示される。
--help 標準出力に使用方法のメッセージを出力して正常終了する。
--version
標準出力にバージョン情報を出力して正常終了する。
例
一昨日の日付を表示するには:
date --date ´2 days ago´
3 ヶ月と 1 日後の日付を表示するには:
date --date ´3 months 1 day´
今年のクリスマスが年の初めから何日目かを表示するには:
date --date ´25 Dec´ +%j
完全な月名と日付からなる書式で今日を表示するには:
date ´+%B %d´
しかしこの結果はお望みのものではないかもしれない。なぜなら月の最初の 9
日を表示させるとき、`%d´ は 2 桁のフィールドの最初を 0 で埋めるからであ
る。例えば `date -d 1-may ´+%B %d´´ の結果は `May 01´ となる。
同じ日を、1 桁の日付の前に 0 を置かないように表示するには、標準にはない
`-´ 修正子を用いて 0 埋めを行わないようにすればよい。
date -d 1-may ´+%B %-d´
注意
プ ログラムのバグについては bug-sh-utils@gnu.org に報告してください。ペ
ージの更新は Ragnar Hojland Espinosa
DATE(1) User Commands DATE(1)
NAME
date - print or set the system date and time
SYNOPSIS
date [OPTION]... [+FORMAT]
date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
DESCRIPTION
Display the current time in the given FORMAT, or set the system date.
-d, --date=STRING
display time described by STRING, not ‘now’
-f, --file=DATEFILE
like --date once for each line of DATEFILE
-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’, ‘sec-
onds’, or ‘ns’ for date and time to the indicated precision.
Date and time components are separated by a 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
--help display this help and exit
--version
output version information and exit
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 ( 0..23)
%l hour ( 1..12)
%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 timezone (e.g., -0400)
%:z +hh:mm numeric timezone (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
After any flags comes an optional field width, as a decimal number;
then an optional modifier, which is either E to use the locale’s alter-
nate representations if available, or O to use the locale’s alternate
numeric symbols if available.
DATE STRING
The --date=STRING is a mostly free format human readable date string
such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or
even "next Thursday". A date string may contain items indicating cal-
endar date, time of day, time zone, day of week, relative time, rela-
tive date, and numbers. An empty string indicates the beginning of the
day. The date string format is more complex than is easily documented
here but is fully described in the info documentation.
ENVIRONMENT
TZ Specifies the timezone, unless overridden by command line param-
eters. If neither is specified, the setting from /etc/localtime
is used.
AUTHOR
Written by David MacKenzie.
REPORTING BUGS
Report date bugs to bug-coreutils@gnu.org
GNU coreutils home page:
Copyright(C) linux-cmd.com All Rights Reserved. Author Takayuki Yukawa