date(1) — Commands
OSF
NAME
date − Displays or sets the date
SYNOPSIS
With Superuser Authority:
date [-nu] [MMddhhmm.ssyy | alternate_date_format] [+field_descriptor ...]
date [-nu] mmddhhmm[yy] [+field_descriptor ...]
Without Superuser Authority:
date [-u] [+field_descriptor ...]
The date command writes the current date and time to standard output.
FLAGS
-nDoes not set the time globally on all machines in a local area network that have their clocks synchronized (superuser only).
-uDisplays and sets time in Coordinated Universal Time (CUT), which is the default.
DESCRIPTION
The date command writes the current date and time to standard output if called with no flags or with a flag list that begins with a + (plus sign). Only a user operating with superuser authority can change the date and time. The LC_TIME variable, if it is defined, controls the ordering of the day and month numbers in the date specifications. The default order is MMddhhmm.ssyy where:
•MM is the month number (01=January)
•dd is the number of the day in the month
•hh is the hour in the day (using a 24-hour clock)
•mm is the minute number
•ss is the number of seconds
•yy is the last two numbers of the year
The alternative ordering is either ddMMhhmm.ssyy, yyMMddhhmm.ss, or yyddMMhhmm.ss. If format yyMM... is specified, the value of yy must be 88 to 99.
The current month, day, hour, and year are default values. The system operates in Coordinated Universal Time (CUT).
If you follow date with a + (plus sign) 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 %%. The date command copies any other characters to standard output without change. date always ends the string with a newline character. Output fields are fixed size (zero padded if necessary).
Do not change the date when the system is in any run mode other than single-user.
The date command prints out a usage message on any unrecognized flags or input.
Field Descriptors
aDisplays the abbreviated day of the week (Sun to Sat or the non-English equivalent).
ADisplays the full weekday name.
bDisplays the abbreviated month name.
BDisplays the full month name.
cDisplays the current date and time representation for a locale.
dDisplays the day of month (01 to 31).
DDisplays the date as mm/dd/yy (the default), or as specified by the LC_TIME environment variable, if defined.
hDisplays the abbreviated month (Jan to Dec or the non-English equivalent).
HDisplays the hour (00 to 23).
IDisplays the hour from 1 to 12 as a decimal number (01, 02, ... 12).
jDisplays the day of year (001 to 366).
mDisplays the month of year (01 to 12).
MDisplays the minute (00 to 59).
nInserts a newline character.
pDisplays the equivalent of a.m. or p.m. for a locale.
rDisplays the time in a.m./p.m. notation (or the non-English equivalent).
SDisplays the second (00 to 59).
tInserts a tab character.
TDisplays the time as hh:mm:ss (the default), or as specified by the LC_TIME environment variable, if defined.
UDisplays the number of the week in the year as a decimal number, for example, 00, 15, 39. Assumes that Sunday is the first day of the week.
wDisplays the day of the week numerically (Sunday = 0).
WDisplays the number of the week in the year as a decimal number, for example, 00, 15, 39. Assumes that Monday is the first day of the week.
xDisplays the current date representation for a locale.
XDisplays the current time representation for a locale.
yDisplays the last two numbers of year (00 to 99).
YDisplays the year with the century (1900 to 1999).
ZDisplays the timezone name or nothing, if no timezone exists.
EXAMPLES
1.To display current date and time, enter:
date
Depending on your current locale, the output might look like one of the following:
Thu Apr 12 13:21:30 EDT 1990
jeu 12 avr 17:21:30 CUT 1990
tor 12 apr 17:21:30 CUT 1990
The first output line is for an American English locale, the second is for a French locale, and the third is for a Danish locale.
2.To set the date and time, enter:
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, enter:
date +"%r %d %h %y (%a)"
This displays the date (assume current year is 1990) shown in Example 2 as:
02:25:03 PM 17 Feb 90 (Fri)
CAUTIONS
Do not change the date while the system is running with more than one user.
RELATED INFORMATION
Functions: getclock(3), gettimeofday(2), setclock(3).
OSF/1 User’s Guide.