date(1) date(1)
date - write and set the date and time
date [ -u ] [ + format ]
date [ -a [ - ] sss<b>.fff ]
date [ -u | -n ] [[ mmdd]HHMM | mmddHHMM[cc]yy ] [ .ss ]
If no argument is given, or if the argument begins with +, 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.
Supplementary code set characters in +format (see below) are recognized
and displayed according to the locale specified in the LC_CTYPE
environment variable [see LANG on environ(5)]. Month and weekday names
are recognized according to the locale specified in the LC_TIME
environment variable, as described below.
-a [ - ] sss<b>.fff
Slowly adjust the time by sss.fff seconds (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.
-n Do not attempt to notify the network time daemon timed(1m) of
the time change (or more accurately the daemon listening to
the timed 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.
-u Display (or set) the date in Greenwich Mean Time (GMTuniversal
time), bypassing the normal conversion to (or from)
local time.
The notation GMT may change in the future to the equivalent
notation UTC (Coordinated Universal Time).
mm is the month number
dd is the day number in the month
HH is the hour number (24 hour system)
MM is the minute number
Page 1
date(1) date(1)
ss is the second(s) number
cc is the century minus one
yy is the last 2 digits of the year number
The month, day, year, and century may be omitted; the current
values are supplied as defaults.
For example:
date 10080045
sets the date to Oct 8, 12:45 AM.
The current year is the default because no year is supplied. The system
operates in GMT. date 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.
After successfully setting the date and time, date displays the new date
according to the default format. The date command uses TZ to determine
the correct time zone information [see environ(5)].
+ format
If the argument begins with +, the output of date is under the
control of the user. Each Field Descriptor, described below, is
preceded by % and is replaced in the output by its corresponding
value. A single % is encoded by %%. 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 EXAMPLE section).
Supplementary code set characters may be used in format.
As noted, month and weekday names are recognized according to the locale
specified in the LC_TIME environment variable [see LANG on environ(5)].
The names are taken from a file whose format is specified in strftime(4).
This file also defines country-specific date and time formats such as %c,
which specifies the default date format. The following form is the
default for %c:
%a %b %e %T %Z %Y
e.g., Fri Dec 23 10:10:42 EST 1988
Field Descriptors (must be preceded by a %):
a locale's abbreviated weekday name
A locale's full weekday name
b locale's abbreviated month name
Page 2
date(1) date(1)
B locale's full month name
c locale's appropriate date and time representation
C century (a year divided by 100 and truncated to an integer) as a
decimal number [00-99]
d day of month as a decimal number [01-31]
D date as %m/%d/%y
e day of month as a decimal number [1-31] (single digits are
preceded by a blank)
h locale's abbreviated month name (alias for %b)
H hour (24-hour clock) as a decimal number [00-23]
I hour (12-hour clock) as a decimal number [01-12]
j day of year as a decimal number [001-366]
m month of year as a decimal number [01-12]
M minute as a decimal number [00-59]
n insert a newline character
p string containing ante-meridian or post-meridian indicator (by
default, AM or PM)
r 12-hour clock time [01-12] using the AM/PM notation, as %I:%M:%S
%p
R time as %H:%M
S seconds as a decimal number [00-61], allows for leap seconds
t insert a tab character
T 24-hour clock time [00-23], as %H:%M:%S
u weekday as a decimal number [1(Monday)-7]
U 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.
V 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)
w weekday as a decimal number [0(Sunday)-6]
W 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.
x locale's appropriate date representation
X locale's appropriate time representation
y year within century (offset from %C) as a decimal number [00-99]
Y year as ccyy (4 digits)
Z timezone name, or no characters if no timezone is determinable
% insert a percent sign character
Modified Field Descriptors (must be preceded by a %):
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.
Page 3
date(1) date(1)
Ec locale's alternative appropriate date and time representation
EC name of the base year (period) in the locale's alternative
representation
Ex locale's alternative date representation
EX locale's alternative time representation
Ey offset from %EC (year only) in the locale's alternative
representation
EY full alternative year representation
Od day of the month using the locale's alternative numeric symbols
Oe day of the month using the locale's alternative numeric symbols
OH hour (24 hour clock) using the locale's alternative numeric
symbols
OI hour (12 hour clock) using the locale's alternative numeric
symbols
Om month using the locale's alternative numeric symbols
OM minutes using the locale's alternative numeric symbols
OS seconds using the locale's alternative numeric symbols
Ou weekday as a number in the locale's alternative representation
(Monday=1)
OU week number of the year (Sunday as first day of the week) using
the locale's alternative numeric symbols
OV week number of the year (Monday as first day of the week, rules
corresponding to %V) using the locale's alternative numeric
symbols
Ow weekday as a number in the locale's alternative representation
(Sunday=0)
OW week number of the year (Monday as first day of the week) using
the locale's alternative numeric symbols
Oy year (offset from %C) in alternative representation
The command
date '+DATE: %m/%d/%y%nTIME: %H:%M:%S'
generates as output:
DATE: 08/01/76
TIME: 14:45:05
ENVIRONMENT VARIABLES [Toc] [Back] The following environment variables affect the execution of date:
LANG provide a default value for the internationalization variables that
are unset or null. If 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.
Page 4
date(1) date(1)
LC_ALL
if set to a non-empty string value, override the values of all the
other internationalization variables.
LC_CTYPE
determine the locale for the interpretation of sequences of bytes of
text data as characters (for example, single - as opposed to multibyte
- characters in arguments).
LC_MESSAGES
determine the locale that should be used to affect the format and
contents of diagnostic messages written to standard error.
LC_TIME
determine the format and contents of date and time strings written
by date
NLSPATH
determine the location of message catalogs for the processing of
LC_MESSAGES.
TZ determine the timezone in which the time and date are written,
unless the -u option is specified. If the TZ variable is not set and
the -u is not specified, an unspecified system default timezone is
used.
When no formatting operand is specified, the output in the POSIX locale
is equivalent to specifying:
date "+%a %b %e %H:%M:%S %Z %Y"
/usr/lib/locale/locale<b>/LC_MESSAGES/uxcore.abi
language-specific message file [See LANG on environ (5).]
syslog(3), strftime(4), timed(1M), timeslave(1M), utmp(4), environ(5)
UX:date:ERROR:No permission
You do not have the appropriate privileges and you try
to change the date.
UX:date:ERROR:bad conversion
The date set is syntactically incorrect.
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
Page 5
date(1) date(1)
of standard time), the results are unpredictable.
If you are running a network-based time service, such as timed, then it
will override any changes you make with the date command.
PPPPaaaaggggeeee 6666 [ Back ]
|