672 lines
23 KiB
HTML
672 lines
23 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>date</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="date"></a> <a name="tag_04_33"></a><!-- date -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_04_33_01"></a>NAME</h4>
|
|
|
|
<blockquote>date - write the date and time</blockquote>
|
|
|
|
<h4><a name="tag_04_33_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<p><code><tt>date</tt> <b>[</b><tt>-u</tt><b>] [</b><tt>+</tt><i>format</i><b>]</b><tt><br>
|
|
<br>
|
|
</tt></code></p>
|
|
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> date</tt> <b>[</b><tt>-u</tt><b>]</b>
|
|
<i>mmddhhmm</i><b>[[</b><i>cc</i><b>]</b><i>yy</i><b>]</b><tt><img src="../images/opt-end.gif" alt="[Option End]" border=
|
|
"0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_04_33_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>date</i> utility shall write the date and time to standard output <sup>[<a href=
|
|
"javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> or attempt
|
|
to set the system date and time. <img src="../images/opt-end.gif" alt="[Option End]" border="0"> By default, the current date and
|
|
time shall be written. If an operand beginning with <tt>'+'</tt> is specified, the output format of <i>date</i> shall be controlled
|
|
by the conversion specifications and other text in the operand.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_04"></a>OPTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>date</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href=
|
|
"../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p>
|
|
|
|
<p>The following option shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt><b>-u</b></dt>
|
|
|
|
<dd>Perform operations as if the <i>TZ</i> environment variable was set to the string <tt>"UTC0"</tt> , or its equivalent
|
|
historical value of <tt>"GMT0"</tt> . Otherwise, <i>date</i> shall use the timezone indicated by the <i>TZ</i> environment variable
|
|
or the system default if that variable is unset or null.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_05"></a>OPERANDS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following operands shall be supported:</p>
|
|
|
|
<dl compact>
|
|
<dt>+<i>format</i></dt>
|
|
|
|
<dd>When the format is specified, each conversion specifier shall be replaced in the standard output by its corresponding value.
|
|
All other characters shall be copied to the output without change. The output shall always be terminated with a
|
|
<newline>.</dd>
|
|
</dl>
|
|
|
|
<h5><a name="tag_04_33_05_01"></a>Conversion Specifications</h5>
|
|
|
|
<dl compact>
|
|
<dt><tt>%a</tt></dt>
|
|
|
|
<dd>Locale's abbreviated weekday name.</dd>
|
|
|
|
<dt><tt>%A</tt></dt>
|
|
|
|
<dd>Locale's full weekday name.</dd>
|
|
|
|
<dt><tt>%b</tt></dt>
|
|
|
|
<dd>Locale's abbreviated month name.</dd>
|
|
|
|
<dt><tt>%B</tt></dt>
|
|
|
|
<dd>Locale's full month name.</dd>
|
|
|
|
<dt><tt>%c</tt></dt>
|
|
|
|
<dd>Locale's appropriate date and time representation.</dd>
|
|
|
|
<dt><tt>%C</tt></dt>
|
|
|
|
<dd>Century (a year divided by 100 and truncated to an integer) as a decimal number [00,99].</dd>
|
|
|
|
<dt><tt>%d</tt></dt>
|
|
|
|
<dd>Day of the month as a decimal number [01,31].</dd>
|
|
|
|
<dt><tt>%D</tt></dt>
|
|
|
|
<dd>Date in the format <i>mm</i>/<i>dd</i>/<i>yy</i>.</dd>
|
|
|
|
<dt><tt>%e</tt></dt>
|
|
|
|
<dd>Day of the month as a decimal number [1,31] in a two-digit field with leading space character fill.</dd>
|
|
|
|
<dt><tt>%h</tt></dt>
|
|
|
|
<dd>A synonym for <tt>%b</tt> .</dd>
|
|
|
|
<dt><tt>%H</tt></dt>
|
|
|
|
<dd>Hour (24-hour clock) as a decimal number [00,23].</dd>
|
|
|
|
<dt><tt>%I</tt></dt>
|
|
|
|
<dd>Hour (12-hour clock) as a decimal number [01,12].</dd>
|
|
|
|
<dt><tt>%j</tt></dt>
|
|
|
|
<dd>Day of the year as a decimal number [001,366].</dd>
|
|
|
|
<dt><tt>%m</tt></dt>
|
|
|
|
<dd>Month as a decimal number [01,12].</dd>
|
|
|
|
<dt><tt>%M</tt></dt>
|
|
|
|
<dd>Minute as a decimal number [00,59].</dd>
|
|
|
|
<dt><tt>%n</tt></dt>
|
|
|
|
<dd>A <newline>.</dd>
|
|
|
|
<dt><tt>%p</tt></dt>
|
|
|
|
<dd>Locale's equivalent of either AM or PM.</dd>
|
|
|
|
<dt><tt>%r</tt></dt>
|
|
|
|
<dd>12-hour clock time [01,12] using the AM/PM notation; in the POSIX locale, this shall be equivalent to <tt>%I</tt> : <tt>%M</tt>
|
|
: <tt>%S</tt> <tt>%p</tt> .</dd>
|
|
|
|
<dt><tt>%S</tt></dt>
|
|
|
|
<dd>Seconds as a decimal number [00,60].</dd>
|
|
|
|
<dt><tt>%t</tt></dt>
|
|
|
|
<dd>A <tab>.</dd>
|
|
|
|
<dt><tt>%T</tt></dt>
|
|
|
|
<dd>24-hour clock time [00,23] in the format <i>HH</i>:<i>MM</i>:<i>SS</i>.</dd>
|
|
|
|
<dt><tt>%u</tt></dt>
|
|
|
|
<dd>Weekday as a decimal number [1,7] (1=Monday).</dd>
|
|
|
|
<dt><tt>%U</tt></dt>
|
|
|
|
<dd>Week of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first
|
|
Sunday shall be considered to be in week 0.</dd>
|
|
|
|
<dt><tt>%V</tt></dt>
|
|
|
|
<dd>Week of the year (Monday as the first day of the week) as a decimal number [01,53]. If the week containing January 1 has four
|
|
or more days in the new year, then it shall be considered week 1; otherwise, it shall be the last week of the previous year, and
|
|
the next week shall be week 1.</dd>
|
|
|
|
<dt><tt>%w</tt></dt>
|
|
|
|
<dd>Weekday as a decimal number [0,6] (0=Sunday).</dd>
|
|
|
|
<dt><tt>%W</tt></dt>
|
|
|
|
<dd>Week of the year (Monday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first
|
|
Monday shall be considered to be in week 0.</dd>
|
|
|
|
<dt><tt>%x</tt></dt>
|
|
|
|
<dd>Locale's appropriate date representation.</dd>
|
|
|
|
<dt><tt>%X</tt></dt>
|
|
|
|
<dd>Locale's appropriate time representation.</dd>
|
|
|
|
<dt><tt>%y</tt></dt>
|
|
|
|
<dd>Year within century [00,99].</dd>
|
|
|
|
<dt><tt>%Y</tt></dt>
|
|
|
|
<dd>Year with century as a decimal number.</dd>
|
|
|
|
<dt><tt>%Z</tt></dt>
|
|
|
|
<dd>Timezone name, or no characters if no timezone is determinable.</dd>
|
|
|
|
<dt><tt>%%</tt></dt>
|
|
|
|
<dd>A percent sign character.</dd>
|
|
</dl>
|
|
|
|
<p>See the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap07.html#tag_07_03_05">Section
|
|
7.3.5, LC_TIME</a> for the conversion specifier values in the POSIX locale.</p>
|
|
|
|
<h5><a name="tag_04_33_05_02"></a>Modified Conversion Specifications</h5>
|
|
|
|
<p>Some conversion specifiers can be modified by the <tt>E</tt> and <tt>O</tt> modifier characters to indicate a different format
|
|
or specification as specified in the <i>LC_TIME</i> locale description (see the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap07.html#tag_07_03_05">Section 7.3.5, LC_TIME</a>). If the
|
|
corresponding keyword (see <b>era</b>, <b>era_year</b>, <b>era_d_fmt</b>, and <b>alt_digits</b> in the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap07.html#tag_07_03_05">Section 7.3.5, LC_TIME</a>) is not specified or
|
|
not supported for the current locale, the unmodified conversion specifier value shall be used.</p>
|
|
|
|
<dl compact>
|
|
<dt><tt>%Ec</tt></dt>
|
|
|
|
<dd>Locale's alternative appropriate date and time representation.</dd>
|
|
|
|
<dt><tt>%EC</tt></dt>
|
|
|
|
<dd>The name of the base year (period) in the locale's alternative representation.</dd>
|
|
|
|
<dt><tt>%Ex</tt></dt>
|
|
|
|
<dd>Locale's alternative date representation.</dd>
|
|
|
|
<dt><tt>%EX</tt></dt>
|
|
|
|
<dd>Locale's alternative time representation.</dd>
|
|
|
|
<dt><tt>%Ey</tt></dt>
|
|
|
|
<dd>Offset from <tt>%EC</tt> (year only) in the locale's alternative representation.</dd>
|
|
|
|
<dt><tt>%EY</tt></dt>
|
|
|
|
<dd>Full alternative year representation.</dd>
|
|
|
|
<dt><tt>%Od</tt></dt>
|
|
|
|
<dd>Day of month using the locale's alternative numeric symbols.</dd>
|
|
|
|
<dt><tt>%Oe</tt></dt>
|
|
|
|
<dd>Day of month using the locale's alternative numeric symbols.</dd>
|
|
|
|
<dt><tt>%OH</tt></dt>
|
|
|
|
<dd>Hour (24-hour clock) using the locale's alternative numeric symbols.</dd>
|
|
|
|
<dt><tt>%OI</tt></dt>
|
|
|
|
<dd>Hour (12-hour clock) using the locale's alternative numeric symbols.</dd>
|
|
|
|
<dt><tt>%Om</tt></dt>
|
|
|
|
<dd>Month using the locale's alternative numeric symbols.</dd>
|
|
|
|
<dt><tt>%OM</tt></dt>
|
|
|
|
<dd>Minutes using the locale's alternative numeric symbols.</dd>
|
|
|
|
<dt><tt>%OS</tt></dt>
|
|
|
|
<dd>Seconds using the locale's alternative numeric symbols.</dd>
|
|
|
|
<dt><tt>%Ou</tt></dt>
|
|
|
|
<dd>Weekday as a number in the locale's alternative representation (Monday = 1).</dd>
|
|
|
|
<dt><tt>%OU</tt></dt>
|
|
|
|
<dd>Week number of the year (Sunday as the first day of the week) using the locale's alternative numeric symbols.</dd>
|
|
|
|
<dt><tt>%OV</tt></dt>
|
|
|
|
<dd>Week number of the year (Monday as the first day of the week, rules corresponding to <tt>%V</tt> ), using the locale's
|
|
alternative numeric symbols.</dd>
|
|
|
|
<dt><tt>%Ow</tt></dt>
|
|
|
|
<dd>Weekday as a number in the locale's alternative representation (Sunday = 0).</dd>
|
|
|
|
<dt><tt>%OW</tt></dt>
|
|
|
|
<dd>Week number of the year (Monday as the first day of the week) using the locale's alternative numeric symbols.</dd>
|
|
|
|
<dt><tt>%Oy</tt></dt>
|
|
|
|
<dd>Year (offset from <tt>%C</tt> ) in alternative representation.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<dl compact>
|
|
<dt><i>mmddhhmm</i><b>[[</b><i>cc</i><b>]</b><i>yy</i><b>]</b></dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border=
|
|
"0"><br>
|
|
Attempt to set the system date and time from the value given in the operand. This is only possible if the user has appropriate
|
|
privileges and the system permits the setting of the system date and time. The first <i>mm</i> is the month (number); <i>dd</i> is
|
|
the day (number); <i>hh</i> is the hour (number, 24-hour system); the second <i>mm</i> is the minute (number); <i>cc</i> is the
|
|
century and is the first two digits of the year (this is optional); <i>yy</i> is the last two digits of the year and is optional.
|
|
If century is not specified, then values in the range [69,99] shall refer to years 1969 to 1999 inclusive, and values in the range
|
|
[00,68] shall refer to years 2000 to 2068 inclusive. The current year is the default if <i>yy</i> is omitted. <img src=
|
|
"../images/opt-end.gif" alt="[Option End]" border="0"> <basefont size="2">
|
|
|
|
<dl>
|
|
<dt><b>Note:</b></dt>
|
|
|
|
<dd>It is expected that in a future version of IEEE Std 1003.1-2001 the default century inferred from a 2-digit year will
|
|
change. (This would apply to all commands accepting a 2-digit year as input.)</dd>
|
|
</dl>
|
|
|
|
<basefont size="3"></dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_06"></a>STDIN</h4>
|
|
|
|
<blockquote>
|
|
<p>Not used.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_07"></a>INPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_08"></a>ENVIRONMENT VARIABLES</h4>
|
|
|
|
<blockquote>
|
|
<p>The following environment variables shall affect the execution of <i>date</i>:</p>
|
|
|
|
<dl compact>
|
|
<dt><i>LANG</i></dt>
|
|
|
|
<dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> for
|
|
the precedence of internationalization variables used to determine the values of locale categories.)</dd>
|
|
|
|
<dt><i>LC_ALL</i></dt>
|
|
|
|
<dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd>
|
|
|
|
<dt><i>LC_CTYPE</i></dt>
|
|
|
|
<dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as
|
|
opposed to multi-byte characters in arguments).</dd>
|
|
|
|
<dt><i>LC_MESSAGES</i></dt>
|
|
|
|
<dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard
|
|
error.</dd>
|
|
|
|
<dt><i>LC_TIME</i></dt>
|
|
|
|
<dd>Determine the format and contents of date and time strings written by <i>date</i>.</dd>
|
|
|
|
<dt><i>NLSPATH</i></dt>
|
|
|
|
<dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">
|
|
Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt=
|
|
"[Option End]" border="0"></dd>
|
|
|
|
<dt><i>TZ</i></dt>
|
|
|
|
<dd>Determine the timezone in which the time and date are written, unless the <b>-u</b> option is specified. If the <i>TZ</i>
|
|
variable is unset or null and <b>-u</b> is not specified, an unspecified system default timezone is used.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_09"></a>ASYNCHRONOUS EVENTS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_10"></a>STDOUT</h4>
|
|
|
|
<blockquote>
|
|
<p>When no formatting operand is specified, the output in the POSIX locale shall be equivalent to specifying:</p>
|
|
|
|
<pre>
|
|
<tt>date "+%a %b %e %H:%M:%S %Z %Y"
|
|
</tt>
|
|
</pre>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_11"></a>STDERR</h4>
|
|
|
|
<blockquote>
|
|
<p>The standard error shall be used only for diagnostic messages.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_12"></a>OUTPUT FILES</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_13"></a>EXTENDED DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_14"></a>EXIT STATUS</h4>
|
|
|
|
<blockquote>
|
|
<p>The following exit values shall be returned:</p>
|
|
|
|
<dl compact>
|
|
<dt> 0</dt>
|
|
|
|
<dd>The date was written successfully.</dd>
|
|
|
|
<dt>>0</dt>
|
|
|
|
<dd>An error occurred.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_15"></a>CONSEQUENCES OF ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>Default.</p>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_04_33_16"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>Conversion specifiers are of unspecified format when not in the POSIX locale. Some of them can contain <newline>s in some
|
|
locales, so it may be difficult to use the format shown in standard output for parsing the output of <i>date</i> in those
|
|
locales.</p>
|
|
|
|
<p>The range of values for <tt>%S</tt> extends from 0 to 60 seconds to accommodate the occasional leap second.</p>
|
|
|
|
<p>Although certain of the conversion specifiers in the POSIX locale (such as the name of the month) are shown with initial capital
|
|
letters, this need not be the case in other locales. Programs using these fields may need to adjust the capitalization if the
|
|
output is going to be used at the beginning of a sentence.</p>
|
|
|
|
<p>The date string formatting capabilities are intended for use in Gregorian-style calendars, possibly with a different starting
|
|
year (or years). The <tt>%x</tt> and <tt>%c</tt> conversion specifications, however, are intended for local representation; these
|
|
may be based on a different, non-Gregorian calendar.</p>
|
|
|
|
<p>The <tt>%C</tt> conversion specification was introduced to allow a fallback for the <tt>%EC</tt> (alternative year format base
|
|
year); it can be viewed as the base of the current subdivision in the Gregorian calendar. The century number is calculated as the
|
|
year divided by 100 and truncated to an integer; it should not be confused with the use of ordinal numbers for centuries (for
|
|
example, "twenty-first century".) Both the <tt>%Ey</tt> and <tt>%y</tt> can then be viewed as the offset from <tt>%EC</tt> and
|
|
<tt>%C</tt> , respectively.</p>
|
|
|
|
<p>The <tt>E</tt> and <tt>O</tt> modifiers modify the traditional conversion specifiers, so that they can always be used, even if
|
|
the implementation (or the current locale) does not support the modifier.</p>
|
|
|
|
<p>The <tt>E</tt> modifier supports alternative date formats, such as the Japanese Emperor's Era, as long as these are based on the
|
|
Gregorian calendar system. Extending the <tt>E</tt> modifiers to other date elements may provide an implementation-defined
|
|
extension capable of supporting other calendar systems, especially in combination with the <tt>O</tt> modifier.</p>
|
|
|
|
<p>The <tt>O</tt> modifier supports time and date formats using the locale's alternative numerical symbols, such as Kanji or Hindi
|
|
digits or ordinal number representation.</p>
|
|
|
|
<p>Non-European locales, whether they use Latin digits in computational items or not, often have local forms of the digits for use
|
|
in date formats. This is not totally unknown even in Europe; a variant of dates uses Roman numerals for the months: the third day
|
|
of September 1991 would be written as 3.IX.1991. In Japan, Kanji digits are regularly used for dates; in Arabic-speaking countries,
|
|
Hindi digits are used. The <tt>%d</tt> , <tt>%e</tt> , <tt>%H</tt> , <tt>%I</tt> , <tt>%m</tt> , <tt>%S</tt> , <tt>%U</tt> ,
|
|
<tt>%w</tt> , <tt>%W</tt> , and <tt>%y</tt> conversion specifications always return the date and time field in Latin digits (that
|
|
is, 0 to 9). The <tt>%O</tt> modifier was introduced to support the use for display purposes of non-Latin digits. In the
|
|
<i>LC_TIME</i> category in <a href="../utilities/localedef.html"><i>localedef</i></a>, the optional <b>alt_digits</b> keyword is
|
|
intended for this purpose. As an example, assume the following (partial) <a href="../utilities/localedef.html"><i>localedef</i></a>
|
|
source:</p>
|
|
|
|
<pre>
|
|
<tt>alt_digits "";"I";"II";"III";"IV";"V";"VI";"VII";"VIII" \
|
|
"IX";"X";"XI";"XII"
|
|
d_fmt "%e.%Om.%Y"
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>With the above date, the command:</p>
|
|
|
|
<pre>
|
|
<tt>date "+%x"
|
|
</tt>
|
|
</pre>
|
|
|
|
<p>would yield 3.IX.1991. With the same <b>d_fmt</b>, but without the <b>alt_digits</b>, the command would yield 3.9.1991.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_17"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<ol>
|
|
<li>
|
|
<p>The following are input/output examples of <i>date</i> used at arbitrary times in the POSIX locale:</p>
|
|
|
|
<pre>
|
|
<b>$</b> <tt>date
|
|
</tt><b>Tue Jun 26 09:58:10 PDT 1990
|
|
<br>
|
|
$</b> <tt>date "+DATE: %m/%d/%y%nTIME: %H:%M:%S"
|
|
</tt><b>DATE: 11/02/91
|
|
TIME: 13:36:16
|
|
<br>
|
|
$</b> <tt>date "+TIME: %r"
|
|
</tt><b>TIME: 01:36:32 PM</b>
|
|
</pre>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Examples for Denmark, where the default date and time format is <tt>%a</tt> <tt>%d</tt> <tt>%b</tt> <tt>%Y</tt> <tt>%T</tt>
|
|
<tt>%Z</tt> :</p>
|
|
|
|
<pre>
|
|
<b>$</b> <tt>LANG=da_DK.iso_8859-1 date
|
|
</tt><b>ons 02 okt 1991 15:03:32 CET
|
|
<br>
|
|
$</b> <tt>LANG=da_DK.iso_8859-1 \
|
|
date "+DATO: %A den %e. %B %Y%nKLOKKEN: %H:%M:%S"
|
|
</tt><b>DATO: onsdag den 2. oktober 1991
|
|
KLOKKEN: 15:03:56</b>
|
|
</pre>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Examples for Germany, where the default date and time format is <tt>%a</tt> <tt>%d</tt> . <tt>%h</tt> . <tt>%Y</tt> ,
|
|
<tt>%T</tt> <tt>%Z</tt> :</p>
|
|
|
|
<pre>
|
|
<b>$</b> <tt>LANG=De_DE.88591 date
|
|
</tt><b>Mi 02.Okt.1991, 15:01:21 MEZ
|
|
<br>
|
|
$</b> <tt>LANG=De_DE.88591 date "+DATUM: %A, %d. %B %Y%nZEIT: %H:%M:%S"
|
|
</tt><b>DATUM: Mittwoch, 02. Oktober 1991
|
|
ZEIT: 15:02:02</b>
|
|
</pre>
|
|
</li>
|
|
|
|
<li>
|
|
<p>Examples for France, where the default date and time format is <tt>%a</tt> <tt>%d</tt> <tt>%h</tt> <tt>%Y</tt> <tt>%Z</tt>
|
|
<tt>%T</tt> :</p>
|
|
|
|
<pre>
|
|
<b>$</b> <tt>LANG=Fr_FR.88591 date
|
|
</tt><b>Mer 02 oct 1991 MET 15:03:32
|
|
<br>
|
|
$</b> <tt>LANG=Fr_FR.88591 date "+JOUR: %A %d %B %Y%nHEURE: %H:%M:%S"
|
|
</tt><b>JOUR: Mercredi 02 octobre 1991
|
|
HEURE: 15:03:56</b>
|
|
</pre>
|
|
</li>
|
|
</ol>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_18"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>Some of the new options for formatting are from the ISO C standard. The <b>-u</b> option was introduced to allow portable
|
|
access to Coordinated Universal Time (UTC). The string <tt>"GMT0"</tt> is allowed as an equivalent <i>TZ</i> value to be compatible
|
|
with all of the systems using the BSD implementation, where this option originated.</p>
|
|
|
|
<p>The <tt>%e</tt> format conversion specification (adopted from System V) was added because the ISO C standard conversion
|
|
specifications did not provide any way to produce the historical default <i>date</i> output during the first nine days of any
|
|
month.</p>
|
|
|
|
<p>There are two varieties of day and week numbering supported (in addition to any others created with the locale-dependent
|
|
<tt>%E</tt> and <tt>%O</tt> modifier characters):</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>The historical variety in which Sunday is the first day of the week and the weekdays preceding the first Sunday of the year are
|
|
considered week 0. These are represented by <tt>%w</tt> and <tt>%U</tt> . A variant of this is <tt>%W</tt> , using Monday as the
|
|
first day of the week, but still referring to week 0. This view of the calendar was retained because so many historical
|
|
applications depend on it and the ISO C standard <a href="../functions/strftime.html"><i>strftime</i>()</a> function, on which
|
|
many <i>date</i> implementations are based, was defined in this way.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The international standard, based on the ISO 8601:2000 standard where Monday is the first weekday and the algorithm for the
|
|
first week number is more complex: If the week (Monday to Sunday) containing January 1 has four or more days in the new year, then
|
|
it is week 1; otherwise, it is week 53 of the previous year, and the next week is week 1. These are represented by the new
|
|
conversion specifications <tt>%u</tt> and <tt>%V</tt> , added as a result of international comments.</p>
|
|
</li>
|
|
</ul>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_19"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_20"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p>The System Interfaces volume of IEEE Std 1003.1-2001, <a href="../functions/printf.html"><i>printf</i>()</a>, <a href=
|
|
"../functions/strftime.html"><i>strftime</i>()</a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_21"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 2.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_22"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>Changes are made for Year 2000 alignment.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_04_33_23"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The following new requirements on POSIX implementations derive from alignment with the Single UNIX Specification:</p>
|
|
|
|
<ul>
|
|
<li>
|
|
<p>The setting of system date and time is described, including how to interpret two-digit year values if a century is not
|
|
given.</p>
|
|
</li>
|
|
|
|
<li>
|
|
<p>The <tt>%EX</tt> modified conversion specification is added.</p>
|
|
</li>
|
|
</ul>
|
|
|
|
<p>The Open Group Corrigendum U048/2 is applied, correcting the examples.</p>
|
|
|
|
<p>The DESCRIPTION is updated to refer to conversion specifications, instead of field descriptors for consistency with the
|
|
<i>LC_TIME</i> category.</p>
|
|
|
|
<p>A clarification is made such that the current year is the default if the <i>yy</i> argument is omitted when setting the system
|
|
date and time.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|