date(1)
date --
print and set the date
Synopsis
date [-u] [+format]
date [-u] [[mmdd]HHMM | mmddHHMM[[cc]yy]]
date [-a [-]sss.fff]
Description
If no argument is given,
or if the argument begins with +,
the current date and time are printed.
Otherwise, the current date is set for the real-time clock and the
system clock
if the user is a privilege user.
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.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.
-u-
Display (or set) the date in Coordinated Universal Time or Greenwich Mean Time,
bypassing the normal conversion to
(or from) local 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
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.
Only a privileged user may change the date.
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 LANG on
environ(5)).
+ format-
If the argument begins with +,
the output of date is under the control of the user.
Each Field Descriptor 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 new-line 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(3C).
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
For example: Fri Dec 23 10:10:42 EST 1992
Field Descriptors (must be preceded by a ``%''):
a-
abbreviated weekday name
A-
full weekday name
b-
abbreviated month name
B-
full month name
c-
country-specific date and time format
C-
century as a decimal integer (equivalent to the year divided by 100)
d-
day of month - 01 to 31
D-
date as %m/%d/%y
e-
day of month - 1 to 31 (single digits are preceded by a blank)
h-
abbreviated month name (alias for %b)
H-
hour - 00 to 23
I-
hour - 01 to 12
j-
day of year - 001 to 366
m-
month of year - 01 to 12
M-
minute - 00 to 59
n-
insert a new-line character
p-
string containing ante-meridian or post-meridian
indicator (by default, AM or PM)
r-
time as %I:%M:%S %p
R-
time as %H:%M
S-
second - 00 to 61, allows for leap seconds
t-
insert a tab character
T-
time as %H:%M:%S
u-
weekday as a decimal number (1 for Monday - 7 for Sunday)
U-
week number of year (Sunday as the first day of the week) - 00 to 53;
all days before the first Sunday in the new year are considered to be in week 0
V-
week number of year (Monday as the first day of the week) - 00 to 53;
the week of January 1 is week 1 if it has more than three days in the new year,
otherwise, it is week 53 of the previous year and the next week is week 1
w-
day of week - Sunday = 0
W-
week number of year (Monday as the first day of the week) - 00 to 53;
all days before the first Sunday in the new year are considered to be in week 0
x-
country-specific date format
X-
country-specific time format
y-
year within century - 00 to 99
Y-
year as ccyy (4 digits)
Z-
abbreviated timezone name
%-
a percent sign
Some of the field descriptors above can be modified by prepending them
with an ``E'' or ``O'', resulting in the following descriptors.
Modified Field Descriptors (must be preceded by a ``%''):
Ec-
Alternate appropriate date and time representation.
EC-
Name of the base year (period) in locale's alternate representation.
Ex-
Locale's alternate date representation.
EX-
Locale's alternate time representation.
Ey-
Offset from %EC (year only) in locale's alternate representation.
EY-
Full alternate year representation.
Od-
Day of month using locale's alternate numeric symbols.
Oe-
Day of month using locale's alternate numeric symbols.
OH-
Hour (24 hr clock) using locale's alternate numeric symbols.
OI-
Hour (12 hr clock) using locale's alternate numeric symbols.
Om-
Month using locale's alternate numeric symbols.
OM-
Minutes using locale's alternate numeric symbols.
OS-
Seconds using locale's alternate numeric symbols.
Ou-
Weekday as a number in the locale's alternate representation (Monday = 1).
OU-
Week number of year (Sunday is 1st day of week) using locale's alternate
numeric symbols.
OV-
Week number of the year (rules as for %V) using the locale's
alternate numeric symbols.
Ow-
Week day as number in locale's alternate representation (Sunday = 0).
OW-
Week number of year (Monday is 1st day of week) using locale's
alternate numeric symbols.
Oy-
Year (offset from %C) in alternate representation.
Usage
Examples
The command
date '+DATE: %m/%d/%y%nTIME: %H:%M:%S'
generates as output:
DATE: 08/01/76
TIME: 14:45:05
Errors
UX:date:ERROR:No permission
-
You are not a privileged user
and you try to change the date.
UX:date:ERROR:bad conversion
-
The date set is syntactically incorrect.
Files
/usr/lib/locale/locale/LC_MESSAGES/uxcore.abi-
language-specific message file
(see LANG on
environ(5)).
References
environ(5),
strftime(4)
© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 25 April 2004