date
PURPOSE
Displays or sets the date.
SYNOPSIS
date [ [ [ date ] dd ] time [ .ss ] [ yy ] ] [ + format ]
Operating With Superuser Authority
Operating Without Superuser Authority
DESCRIPTION
Warning: Do not change the date while the system is
running with more than one user.
If called with no flags or with a flag list that begins
with a + (plus sign), the date command writes the current
date and time to standard output. Otherwise, it sets the
current date. Only a user operating with superuser
authority can change the date and time. The NLDATE vari-
able, if it is defined, controls the ordering of the day
and month numbers in the date specifications. The
default order is MMddhhmm.ssyy where:
o MM is the month number
o dd is the number of the day in the month
o hh is the hour in the day (using a 24-hour clock)
o mm is the minute number
o .ss is the number of seconds
o yy is the last two numbers of the year.
The alternative ordering is ddMMhhmm.ssyy.
The current month, day, hour, and year are default
values. The system operates in Greenwich Mean Time
(GMT). date takes care of the conversion to and from
local standard and daylight time as specified in the NLTZ
environmental variable.
If you follow date with a + and a field descriptor, you
can control the output of the command. You must precede
each field descriptor with a percent sign ("%"). The
system replaces the field descriptor with the specified
value. Enter a literal "%" as "%%". date copies any
other characters to the output without change. date
always ends the string with a new-line character. Output
fields are fixed size (zero padded if necessary).
FIELD DESCRIPTORS
a Displays the abbreviated day of the week ("Sun" to
"Sat" or the non-English equivalent).
d Displays the day of month ("01" to "31").
D Displays the date as mm/dd/yy (the default), or as
dd/mm/yy. This format is specified by the NLDATE
environment variable, if defined.
h Displays the abbreviated month ("Jan" to "Dec" or
the non-English equivalent).
H Displays the hour ("00" to "23").
j Displays the day of year ("001" to "366").
m Displays the month of year ("01" to "12").
M Displays the minute ("00" to "59")
n Inserts a new-line character.
r Displays the time in AM/PM notation (or the non-
English equivalent).
S Displays the second ("00" to "59").
t Inserts a tab character.
T Displays the time as hh:mm:ss (the default), or as
mm:hh:ss. This format is specified by the NLTIME
environment variable, if defined.
w Displays the day of the week numerically (Sunday =
"0").
y Displays the last two numbers of year ("00" to
"99").
EXAMPLES
1. To display current date and time:
date
2. To set the date and time:
date 02171425.45
This sets the date and time to 14:25:45 (45 seconds
after 2:25 p.m.) February 17 of the current year.
3. To display the date and time in a specified format:
date +"%r %a %d %h %y (Julian Date: %j)"
This displays the date (assume current year is 1984)
shown in Example 2 as:
02:25:03 PM Fri 17 Feb 84 (Julian Date: 048)
FILES
/dev/kmem
RELATED INFORMATION
See the time and stime system calls and the environment
miscellaneous facility in AIX Operating System Technical
Reference.
"Overview of International Character Support" in Managing
the AIX Operating System.