468 lines
11 KiB
Groff
468 lines
11 KiB
Groff
'\"macro stdmacro
|
|
.if n .pH g1.date @(#)date 41.13 of 5/26/91
|
|
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 AT&T
|
|
.nr X
|
|
.if \nX=0 .ds x} date 1 "Essential Utilities" "\&"
|
|
.if \nX=1 .ds x} date 1 "Essential Utilities"
|
|
.if \nX=2 .ds x} date 1 "" "\&"
|
|
.if \nX=3 .ds x} date "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
\f4date\f1 \- write and set the date and time
|
|
.SH SYNOPSIS
|
|
\f4date\f1 [
|
|
\f4-u\fP
|
|
]
|
|
[
|
|
\f4+\fP
|
|
.I format
|
|
]
|
|
.br
|
|
\f4date\f1
|
|
[
|
|
\f4-a\f1
|
|
[
|
|
\f4\-\f1
|
|
]
|
|
\f2sss\f4.\f2fff\f1
|
|
]
|
|
.br
|
|
\f4date\f1
|
|
[
|
|
\f4\-u\f1
|
|
|
|
|
\f4\-n\f1
|
|
]
|
|
[\|[
|
|
.IR mmdd \|]\| HHMM
|
|
|
|
|
.IR mmddHHMM \|[\| cc \|]\| yy
|
|
]
|
|
[
|
|
.IR .ss
|
|
]
|
|
.SH DESCRIPTION
|
|
If no argument is given,
|
|
or if the argument begins with \f4+\f1,
|
|
the current date and time are printed.
|
|
Otherwise, the current date is set
|
|
if the user has appropriate privileges and the system permits
|
|
the setting of the system date and time.
|
|
.P
|
|
Supplementary code set characters in \f4+\f2format\f1
|
|
(see below) are recognized and displayed
|
|
according to the locale specified in the \f4LC_CTYPE\fP
|
|
environment variable [see \f4LANG\fP on \f4environ\fP(5)].
|
|
Month and weekday names are recognized according
|
|
to the locale specified in the \f4LC_TIME\f1 environment variable,
|
|
as described below.
|
|
.SH OPTIONS
|
|
.PP
|
|
.TP 12
|
|
\f4\-a\f1 [ \f4\-\f1 ] \f2sss\f4.\f2fff\f1
|
|
Slowly adjust the time by
|
|
.IR sss . fff
|
|
seconds
|
|
.RI ( fff
|
|
represents fractions of a second).
|
|
This adjustment can be positive or negative.
|
|
The system's clock will be sped up or slowed down until it has drifted
|
|
by the number of seconds specified.
|
|
.TP
|
|
\f4\-n\f1
|
|
Do not attempt to notify the network time daemon
|
|
.IR timed (1m)
|
|
of the time change (or more accurately the daemon listening to
|
|
the \f4timed\fP UDP port). This option should be used if you
|
|
are not using that daemon. If not used, the daemon is notified
|
|
of the date change, and if it is acting as the master, the date
|
|
change will be broadcast to the time daemons on other systems.
|
|
.TP
|
|
\f4\-u\f1
|
|
Display (or set) the date in Greenwich Mean Time
|
|
(\s-1GMT\s0\(emuniversal time),
|
|
bypassing the normal conversion to
|
|
(or from) local time.
|
|
.TP
|
|
\f4\ \f1
|
|
The notation GMT may change in the future
|
|
to the equivalent notation UTC (Coordinated Universal Time).
|
|
.TP
|
|
.I mm\^
|
|
is the month number
|
|
.TP
|
|
.I dd\^
|
|
is the day number in the month
|
|
.TP
|
|
.I HH\^
|
|
is the hour number (24 hour system)
|
|
.TP
|
|
.I MM\^
|
|
is the minute number
|
|
.TP
|
|
.I ss\^
|
|
is the second(s) number
|
|
.TP
|
|
.I cc\^
|
|
is the century minus one
|
|
.TP
|
|
.I yy\^
|
|
is the last 2 digits of the year number
|
|
.IP
|
|
The month, day, year, and century may be omitted;
|
|
the current values are supplied as defaults.
|
|
.PP
|
|
For example:
|
|
.IP "" 18
|
|
\f4date\| 10080045\fP
|
|
.IP "" 12
|
|
sets the date to Oct 8, 12:45 \s-1AM\s+1.
|
|
.PP
|
|
The current year is the default because no year is supplied.
|
|
The system operates in \s-1GMT\s0.
|
|
\f4date\fP
|
|
takes care of the conversion to and from
|
|
local standard and daylight time.
|
|
The date can be changed only if the user has appropriate privileges
|
|
and the system permits the setting of the system date and time.
|
|
.PP
|
|
After successfully setting the date and time,
|
|
\f4date\fP
|
|
displays the new date according
|
|
to the default format.
|
|
The \f4date\fP
|
|
command uses
|
|
\f4TZ\fP
|
|
to determine the correct time zone information
|
|
[see
|
|
\f4environ\fP(5)].
|
|
.SH OPERANDS
|
|
.TP
|
|
\f4+\fP \f2format\fP
|
|
If the argument begins with \f4+\fP,
|
|
the output of
|
|
\f4date\fP
|
|
is under the control of the user.
|
|
Each Field Descriptor, described below, is preceded by \f4%\fP
|
|
and is replaced in the output by
|
|
its corresponding value.
|
|
A single \f4%\fP is encoded by \f4%%\fP.
|
|
All other
|
|
characters are copied to the output without change.
|
|
The string is always terminated with a newline character.
|
|
If the argument contains embedded blanks
|
|
it must be quoted (see the
|
|
\s-1EXAMPLE\s0
|
|
section).
|
|
Supplementary code set characters may be used in \f2format\f1.
|
|
.PP
|
|
As noted, month and weekday names are recognized
|
|
according to the locale specified in the \f4LC_TIME\fP
|
|
environment variable [see \f4LANG\fP on \f4environ\fP(5)].
|
|
The names are taken from a file whose format is specified in
|
|
\f4strftime\fP(4).
|
|
This file also defines country-specific date and
|
|
time formats such as \f4%c\fP,
|
|
which specifies the default date format.
|
|
The following form is the default for \f4%c\fP:
|
|
.sp .5
|
|
.RS
|
|
.nf
|
|
\f4%a %b %e %T %Z %Y\fP
|
|
e.g., Fri Dec 23 10:10:42 EST 1988
|
|
.fi
|
|
.RE
|
|
.PP
|
|
Field Descriptors (must be preceded by a \f4%\fP):
|
|
.sp .5
|
|
.RS 3
|
|
.PD 0
|
|
.TP 5
|
|
\f4 a\f1
|
|
locale's abbreviated weekday name
|
|
.TP 5
|
|
\f4 A\f1
|
|
locale's full weekday name
|
|
.TP 5
|
|
\f4 b\f1
|
|
locale's abbreviated month name
|
|
.TP 5
|
|
\f4 B\f1
|
|
locale's full month name
|
|
.TP 5
|
|
\f4 c\f1
|
|
locale's appropriate date and time representation
|
|
.TP 5
|
|
\f4 C\f1
|
|
century (a year divided by 100 and truncated to an integer) as
|
|
a decimal number [00-99]
|
|
.TP 5
|
|
\f4 d\f1
|
|
day of month as a decimal number [01-31]
|
|
.TP 5
|
|
\f4 D\f1
|
|
date as \f4%m/%d/%y\f1
|
|
.TP 5
|
|
\f4 e\f1
|
|
day of month as a decimal number [1-31] (single digits are preceded by a blank)
|
|
.TP 5
|
|
\f4 h\f1
|
|
locale's abbreviated month name (alias for \f4%b\fP)
|
|
.TP 5
|
|
\f4 H\f1
|
|
hour (24-hour clock) as a decimal number [00-23]
|
|
.TP 5
|
|
\f4 I\f1
|
|
hour (12-hour clock) as a decimal number [01-12]
|
|
.TP 5
|
|
\f4 j\f1
|
|
day of year as a decimal number [001-366]
|
|
.TP 5
|
|
\f4 m\f1
|
|
month of year as a decimal number [01-12]
|
|
.TP 5
|
|
\f4 M\f1
|
|
minute as a decimal number [00-59]
|
|
.TP 5
|
|
\f4 n\f1
|
|
insert a newline character
|
|
.TP 5
|
|
\f4 p\f1
|
|
string containing ante-meridian or post-meridian
|
|
indicator (by default, AM or PM)
|
|
.TP 5
|
|
\f4 r\f1
|
|
12-hour clock time [01-12] using the AM/PM notation, as \f4%I:%M:%S %p\f1
|
|
.TP 5
|
|
\f4 R\f1
|
|
time as \f4%H:%M\f1
|
|
.TP 5
|
|
\f4 S\f1
|
|
seconds as a decimal number [00-61], allows for leap seconds
|
|
.TP 5
|
|
\f4 t\f1
|
|
insert a tab character
|
|
.TP 5
|
|
\f4 T\f1
|
|
24-hour clock time [00-23], as \f4%H:%M:%S\f1
|
|
.TP 5
|
|
\f4 u\f1
|
|
weekday as a decimal number [1(Monday)-7]
|
|
.TP 5
|
|
\f4 U\f1
|
|
week number of 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 are considered to be in week 0.
|
|
.TP 5
|
|
\f4 V\f1
|
|
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 is considered week 1;
|
|
otherwise, it is week 53 of the previous year, and
|
|
the next week is week 1. ( See the ISO 8601:1988 standard)
|
|
.sp 0
|
|
.TP 5
|
|
\f4 w\f1
|
|
weekday as a decimal number [0(Sunday)-6]
|
|
.TP 5
|
|
\f4 W\f1
|
|
week of year (Monday as the first day of the week) as a decimal number [00-53].
|
|
All days in a new year preceding the first Sunday
|
|
are considered to be in week 0.
|
|
.TP 5
|
|
\f4 x\f1
|
|
locale's appropriate date representation
|
|
.TP 5
|
|
\f4 X\f1
|
|
locale's appropriate time representation
|
|
.TP 5
|
|
\f4 y\f1
|
|
year within century (offset from %C) as a decimal number [00-99]
|
|
.TP 5
|
|
\f4 Y\f1
|
|
year as \f2ccyy\f1 (4 digits)
|
|
.TP 5
|
|
\f4 Z\f1
|
|
timezone name, or no characters if no timezone is determinable
|
|
.TP 5
|
|
\f4 %\f1
|
|
insert a percent sign character
|
|
.RE
|
|
.PD
|
|
.PP
|
|
Modified Field Descriptors (must be preceded by a \f4%\fP):
|
|
.PP
|
|
Some field descriptors can be modified by the E and O modifier characters
|
|
to indicate a different format or specification as specified in the LC_TIME
|
|
locale description (see the XBD specification). If the corresponding keyword
|
|
is not specified or not supported for the current locale, the unmodified
|
|
field descriptor value will be used.
|
|
.sp .5
|
|
.RS 3
|
|
.PD 0
|
|
.TP 5
|
|
\f4 Ec\f1
|
|
locale's alternative appropriate date and time representation
|
|
.TP 5
|
|
\f4 EC\f1
|
|
name of the base year (period) in the locale's alternative representation
|
|
.TP 5
|
|
\f4 Ex\f1
|
|
locale's alternative date representation
|
|
.TP 5
|
|
\f4 EX\f1
|
|
locale's alternative time representation
|
|
.TP 5
|
|
\f4 Ey\f1
|
|
offset from %EC (year only) in the locale's alternative representation
|
|
.TP 5
|
|
\f4 EY \f1
|
|
full alternative year representation
|
|
.TP 5
|
|
\f4 Od\f1
|
|
day of the month using the locale's alternative numeric symbols
|
|
.TP 5
|
|
\f4 Oe\f1
|
|
day of the month using the locale's alternative numeric symbols
|
|
.TP 5
|
|
\f4 OH\f1
|
|
hour (24 hour clock) using the locale's alternative numeric symbols
|
|
.TP 5
|
|
\f4 OI\f1
|
|
hour (12 hour clock) using the locale's alternative numeric symbols
|
|
.TP 5
|
|
\f4 Om\f1
|
|
month using the locale's alternative numeric symbols
|
|
.TP 5
|
|
\f4 OM\f1
|
|
minutes using the locale's alternative numeric symbols
|
|
.TP 5
|
|
\f4 OS\f1
|
|
seconds using the locale's alternative numeric symbols
|
|
.TP 5
|
|
\f4 Ou\f1
|
|
weekday as a number in the locale's alternative representation (Monday=1)
|
|
.TP 5
|
|
\f4 OU\f1
|
|
week number of the year (Sunday as first day of the week)
|
|
using the locale's alternative numeric symbols
|
|
.TP 5
|
|
\f4 OV\f1
|
|
week number of the year (Monday as first day of the week,
|
|
rules corresponding to %V) using the locale's alternative numeric symbols
|
|
.TP 5
|
|
\f4 Ow\f1
|
|
weekday as a number in the locale's alternative representation (Sunday=0)
|
|
.TP 5
|
|
\f4 OW\f1
|
|
week number of the year (Monday as first day of the week)
|
|
using the locale's alternative numeric symbols
|
|
.TP 5
|
|
\f4 Oy\f1
|
|
year (offset from %C) in alternative representation
|
|
|
|
.RE
|
|
.PD
|
|
.ne 8
|
|
.SH EXAMPLE
|
|
The command
|
|
.IP
|
|
\f4date '+DATE: %m/%d/%y%nTIME: %H:%M:%S'\f1
|
|
.PP
|
|
generates as output:
|
|
.sp .5
|
|
.nf
|
|
\f4DATE: 08/01/76
|
|
TIME: 14:45:05\f1
|
|
.fi
|
|
.br
|
|
.ne 1.5i
|
|
.SH ENVIRONMENT VARIABLES
|
|
The following environment variables affect the execution of
|
|
\f4date\fP:
|
|
.TP
|
|
\f4LANG\fP
|
|
provide a default value for the internationalization variables that are unset or null.
|
|
If
|
|
.I LANG\^
|
|
is unset or null the corresponding value from the implementation-specific
|
|
default locale will be used. If any of the internationalization variables
|
|
contains an invalid setting, the utility will behave as if
|
|
none of the variables had been defined.
|
|
.TP
|
|
\f4LC_ALL\fP
|
|
if set to a non-empty string value, override the values of all the
|
|
other internationalization variables.
|
|
.TP
|
|
\f4LC_CTYPE\fP
|
|
determine the locale for the interpretation of sequences of bytes of
|
|
text data as characters (for example, single - as opposed to multi-byte -
|
|
characters in arguments).
|
|
.TP
|
|
\f4LC_MESSAGES\fP
|
|
determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
|
|
.TP
|
|
\f4LC_TIME\fP
|
|
determine the format and contents of date and time strings written by
|
|
.I date\^
|
|
.
|
|
.TP
|
|
\f4NLSPATH\fP
|
|
determine the location of message catalogs for the processing of
|
|
.I LC_MESSAGES.\^
|
|
.
|
|
.TP
|
|
\f4TZ\fP
|
|
determine the timezone in which the time and date are written, unless the
|
|
.B \-u
|
|
option is specified. If the
|
|
.I TZ\^
|
|
variable is not set and the
|
|
.B \-u
|
|
is not specified, an unspecified system default timezone is used.
|
|
.SH STDOUT
|
|
When no formatting operand is specified, the output in the POSIX locale
|
|
is equivalent to specifying:
|
|
|
|
.sp .5
|
|
.nf
|
|
\f4date "+%a %b %e %H:%M:%S %Z %Y" \f1
|
|
.fi
|
|
.br
|
|
.SH FILES
|
|
.TP
|
|
\f4/usr/lib/locale/\f2locale\f4/LC_MESSAGES/uxcore.abi\f1
|
|
language-specific message file [See \f4LANG\fP on \f4environ\f1 (5).]
|
|
.SH SEE ALSO
|
|
\f4syslog\f1(3),
|
|
\f4strftime\f1(4),
|
|
\f4timed\f1(1M),
|
|
\f4timeslave\f1(1M),
|
|
\f4utmp\f1(4),
|
|
\f4environ\f1(5)
|
|
.SH DIAGNOSTICS
|
|
.PD 0
|
|
.TP 18
|
|
\f5UX:date:ERROR:No permission\f1
|
|
You do not have the appropriate privileges
|
|
and you try to change the date.
|
|
.TP
|
|
\f5UX:date:ERROR:bad conversion\f1
|
|
The date set is syntactically incorrect.
|
|
.PD
|
|
.SH NOTES
|
|
.P
|
|
If you attempt to set the current date to one of the dates
|
|
on which the standard and
|
|
alternate time zones change
|
|
(for example, the date that daylight time is starting or ending),
|
|
and you attempt to set the time to a time in the interval
|
|
between the end of standard time and the beginning of the alternate time
|
|
(or the end of the alternate time and the beginning of standard time),
|
|
the results are unpredictable.
|
|
.P
|
|
If you are running a network-based time service, such as timed, then
|
|
it will override any changes you make with the date command.
|
|
.Ee
|