Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ date(1) — HP-UX 7.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

stime(2)

ctime(3C)

strftime(3C)

tztab(4)

environ(5)

langinfo(5)

lang(5)

DATE(1)

NAME

date − print or set the date and time

SYNOPSIS

date [ mmddhhmm[yy] ] [ +format ]

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, provided you are superuser.  The first mm is the month number; dd is the day number in the month; hh is the hour number (24 hour system); the second mm is the minute number; yy is the last 2 digits of the year number and is optional.  For example:

date 10080045

sets the date to Oct 8, 12:45 a.m.  The current year is the default if no year is mentioned. 

The system operates in Coordinated Universal Time (UCT); date takes care of conversion to and from local standard and daylight time (see Environment Variables below). 

Attempting to set the date backwards generates a warning, and requires an extra confirmation from the (super)user. 

When date is used to set the date, a pair of date change records is written to the file /etc/wtmp. 

In the HP Clustered environment, the date and time are automatically set when the system comes up as a cluster node.  Setting the date and time from any node in a cluster will set the date and time on all nodes in the cluster. 

If the argument begins with +, the output of date is under the control of the user as specified by format.  The format string consists of zero or more directives and ordinary characters.  A directive consists of a % character, an optional field width and precision specification, and a terminating character that determines the directive’s behavior.  All ordinary characters are copied unchanged into the output string and the output string is always terminated with a new-line character. 

If no argument is given, a default format string of %c is used. 

Directives

The following directives, shown without the optional field width and precision specification, are replaced by the indicated characters:

%a abbreviated weekday name

%A full weekday name

%b abbreviated month name

%B full month name

%c current date and time representation

%d day of the month as a decimal number [01,31]

%E combined Emperor/Era name and year

%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 the year as a decimal number [001,366]

%m month as a decimal number [01,12]

%M minute as a decimal number [00,59]

%n new-line character

%N Emperor/Era name

%o Emperor/Era year

%p equivalent of either AM or PM

%S second as a decimal number [00,59]

%t tab character

%U week number of the year (Sunday as the first day of the week) as a decimal number [00,53]

%w weekday as a decimal number [0(Sunday),6]

%W week number of the year (Monday as the first day of the week) as a decimal number [00,53]

%x current date representation

%X current time representation

%y year without century as a decimal number [00,99]

%Y year with century as a decimal number

%Z time zone name (or no characters if time zone cannot be determined)

%% %

The following directives are provided for backward compatibility.  It is recommended that the directives above be used in preference to those below. 

%D date in usual US format (%m/%d/%y) (use %x instead)

%F full month name (use %B instead)

%h abbreviated month name (use %b instead)

%r time in 12-hour US format (%I:%M:%S [AM|PM]) (use %X instead)

%T time in 24-hour US format (%H:%M:%S) (use %X instead)

%z time zone name (or no characters if time zone cannot be determined) (use %Z instead)

If a directive is not one of the above, the behavior is undefined. 

Field Width and Precision

An optional field width and precision specification may immediately follow the initial % of a directive in the following order:

[−|0]w the decimal digit string w specifies a minimum field width in which the result of the conversion is right- or left-justified.  It is right-justified (with space padding) by default.  If the optional flag ‘−’ is specified, it is left-justified with space padding on the right.  If the optional flag ‘0’ is specified, it is right-justified and padded with zeros on the left. 

.p the decimal digit string p specifies the minimum number of digits to appear for the d, H, I, j, m, M, o, S, U, w, W, y and Y directives, and the maximum number of characters to be used from the a, A, b, B, c, D, E, F, h, n, N, p, r, t, T, x, X, z, Z and % directives.  In the first case, if a directive supplies fewer digits than specified by the precision, it will be expanded with leading zeros.  In the second case, if a directive supplies more characters than specified by the precision, excess characters will truncated on the right. 

If no field width or precision is specified for a d, H, I, m, M, S, U, W, y or j directive, a default of ".2" is used for all but j for which ".3" is used. 

DIAGNOSTICS

No permission if you are not the superuser and you try to change the date;

bad conversion if the date set is syntactically incorrect;

bad format character
if the field directive is not recognizable.

EXAMPLES

For example,

date ´+DATE: %m/%d/%y%nTIME: %H:%M:%S´

might generate the following as output:

DATE: 10/08/87
TIME: 12:45:05

Using the date as set in the example given under DESCRIPTION and LC_TIME set to "german",

date ´%-4.4h %2.1d %H:%M´

might generate the following:

Okt    8 12:45

Here, the month field is four bytes long, flush-left, and space-padded on the right if the month name is shorter than four bytes.  The day field is two bytes long, with leading zeros suppressed. 

WARNINGS

It is a bad practice to change the date while the system is running multi-user. 

The A format option was formerly W in HP-UX, but was changed for ANSI compatability. 

AUTHOR

Date was developed by AT&T and HP. 

FILES

/etc/wtmp

SEE ALSO

stime(2), ctime(3C), strftime(3C), tztab(4), environ(5), langinfo(5), lang(5). 

EXTERNAL INFLUENCES

Environment Variables

TZ determines the conversion between the system time in UCT and the time in the user’s local time zone (see environ(5) and tztab(4)). TZ also determines the content (that is, the time-zone name produced by the %z and %Z directives) of date and time strings output by the date command. 

If TZ is not set in the environment or is set to the empty string, a default of EST5EDT is used. 

LC_TIME determines the content (for example, weekday names produced by the %a directive) and format (for example, current time representation produced by the %X directive) of date and time strings output by the date command. 

LC_CTYPE determines the interpretation of the bytes within the format string as single and/or multi-byte characters. 

LC_NUMERIC determines the characters used to form numbers for those directives that produce numbers in the output.  The characters used are those defined by ALT_DIGITS (see langinfo(5)).

LANG determines the language in which messages (other than the date and time strings) are displayed. 

If LC_TIME or LC_CTYPE is not specified in the environment or is set to the empty string, the value of LANG is used as a default for each unspecified or empty variable.  If LANG is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of LANG.  If any internationalization variable contains an invalid setting, date behaves as if all internationalization variables are set to "C".  See environ(5).

International Code Set Support

Single- and multi-byte character code sets are supported. 

STANDARDS CONFORMANCE

date: SVID2, XPG2, XPG3

Hewlett-Packard Company  —  HP-UX Release 7.0: Sept 1989

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026