Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

stime(2)

ctime(3C)

langinfo(3C)

printf(3S)

environ(5)

DATE(1)  —  HP-UX

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 GMT.  Date takes care of the conversion to and from local standard and daylight time by using the TZ environment variable.  The rules applied are the converse of the rules described in ctime(3C). Inspection of the form of the TZ variable will determine the setting of the tz_dsttime variable if gettimeofday(2) is supported on a given system.  Only no conversion and USA standard daylight conversion are defined for this field.  Other conversions defined by TZ will be treated as no conversion for this purpose.

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. 

If the argument begins with +, the output of date is under the control of the user.  The format string describing the output contains field descriptors, as in the first argument to printf(3S). Each field descriptor is preceded by % and will be replaced in the output by its corresponding value.  A single % is encoded by %%.  Non-descriptor characters are copied to the output without change. 

The width and/or precision of a field can be modified by using printf specifiers -- dot (.), dash (-), and digits to indicate a decimal numeric value.  These behave in date just as they do in printf. Numeric output fields are of fixed size (zero-padded if necessary), unless modified by a width/precision specification. Non-numeric fields are of varying size, but can also be modified by a width/precision specification. The output string is always terminated with a new-line character.

Field Descriptors:

n insert a new-line character

t insert a tab character

m month of year − 01 to 12

d day of month − 01 to 31

y last 2 digits of year − 00 to 99

D date as mm/dd/yy

H hour − 00 to 23

M minute − 00 to 59

S second − 00 to 59

T time as HH:MM:SS

j day of year − 001 to 366

w day of week − Sunday = 0

a abbreviated weekday name − Sun to Sat

A full weekday name − Sunday to Saturday

h abbreviated month − Jan to Dec

F full month name − January to December

r time in hh:mm:ss AM/PM notation

p local equivalent of AM/PM

I meridian hour (1-12)

z time zone name from TZ variable in user’s environment

E combined Emperor/Era year and name

N Emperor/Era name

o Emperor/Era year

The full or abbreviated month name and full or abbreviated weekday name are spelled according to user’s native language, as defined by the LANG variable; see environ(5). 

If there is no argument, the current date and time are printed according to the D_T_FMT string (see langinfo(3C)) that corresponds to the current value of the variable LANG in the user’s environment. If the LANG variable is not set, ctime(3C) is used to format the date.

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 descriptor 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,

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

might generate the following:

Oct    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. 

DEPENDENCIES

Series 300 Diskless
In a 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.

AUTHOR

Date was developed by AT&T and HP. 

FILES

/etc/wtmp

SEE ALSO

stime(2), ctime(3C), langinfo(3C), printf(3S), environ(5). 

INTERNATIONAL SUPPORT

Series 300
8-bit data, messages.

Series 800
8- and 16-bit data, messages.

Hewlett-Packard Company  —  May 11, 2021

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