date(1)
NAME
date − print and set the date
SYNOPSIS
date [ −u ] [ + format ]
date [ −a [−] sss.fff ] [ −u ] [[ mmdd]HHMM | mmddHHMM[cc]yy ]
AVAILABILITY
SUNWcsu
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 (only by super-user).
Specifications of native language translations of month and weekday names are supported. The month and weekday names used for a language are based on the locale specified by the environment variables LC_TIME and LANG (see environ(5)).
The month and weekday names used for a language 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
for example,
Fri Dec 23 10:10:42 EST 1988
Field Descriptors (must be preceded by a %):
a abbreviated weekday name
A full weekday name
b abbreviated month name
B full month name
c locale’s appropriate date and time representation
C default date and time format
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-meridiem or post-meridiem 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 week number of year (Sunday as the first day of the week) − 00 to 53
w day of week − Sunday = 0
W week number of year (Monday as the first day of the week) − 00 to 53
x Country-specific date format
X Country-specific time format
y year within century − 00 to 99
Y year as ccyy (4 digits)
Z timezone name
OPTIONS
−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 Greenwich Mean Time (GMT—universal 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 applied 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 the super-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 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 new-line character. If the argument contains embedded blanks it must be quoted (see the EXAMPLES section).
EXAMPLES
The command
example% date ’+DATE: %m/%d/%y%nTIME: %H:%M:%S’
generates as output:
DATE: 08/01/76
TIME: 14:45:05
ENVIRONMENT
If any of the LC_∗ variables (LC_CTYPE, LC_MESSAGES, LC_TIME, LC_COLLATE, LC_NUMERIC, and LC_MONETARY) (see environ(5)) are not set in the environment, the operational behavior of date for each corresponding locale category is determined by the value of the LANG environment variable. If LC_ALL is set, its contents are used to override both the LANG and the other LC_∗ variables. If none of the above variables is set in the environment, the "C" (U.S. style) locale determines how date behaves.
LC_CTYPE
Determines how date handles characters. When LC_CTYPE is set to a valid value, date can display and handle text and filenames containing valid characters for that locale. date can display and handle Extended Unix Code (EUC) characters where any individual character can be 1, 2, or 3 bytes wide. date can also handle EUC characters of 1, 2, or more column widths. In the "C" locale, only characters from ISO 8859-1 are valid.
LC_MESSAGES
Determines how diagnostic and informative messages are presented. This includes the language and style of the messages, and the correct form of affirmative and negative responses. In the "C" locale, the messages are presented in the default form found in the program itself (in most cases, U.S. English).
LC_TIME
Determines how date handles date and time formats. In the "C" locale, date and time handling follows the U.S. rules.
SEE ALSO
DIAGNOSTICS
No permission You are not the super-user and you try to change the date.
bad conversion The date set is syntactically incorrect.
NOTES
If you attempt to set the current date to one of the dates that 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.
SunOS 5.1/SPARC — Last change: 26 Sep 1992