[ Previous | Next | Table of Contents | Index | Library Home |
Legal |
Search ]
Commands Reference, Volume 2
Displays or sets the date or
time.
/usr/bin/date [ -n ] [ -u ] [ Date ] [ +FieldDescriptor ...
]
/usr/bin/date [ -u ] [ +FieldDescriptor
... ]
Attention: Do not
change the date when the system is running with more than one user.
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). Otherwise, it
sets the current date. Only a root user can change the date and
time. The date command prints out the usage message on any
unrecognized flags or input.
The following formats can be used
when setting the date with the Date parameter:
- mmddHHMM[ccyy]
- mmddHHMM[yy]
The variables to the
Date parameter are defined as follows:
mm
| Specifies the month number.
|
dd
| Specifies the number of the day in the month.
|
HH
| Specifies the hour in the day (using a 24-hour clock).
|
MM
| Specifies the minute number.
|
cc
| Specifies the century and is the first two digits of the year.
Note:If you do not specify a century, values in the range
69 to 99 refer to the twentieth century, 1969 to 1999 inclusive, and values in
the range 00 to 68 refer to years in the twenty-first century, 2000 to 2068
inclusive.
|
yy
| Specifies the last two numbers of the year.
|
The current number of seconds and
the current year are used as default values when the SS or
yy variables are not specified. The system operates in
Coordinated Universal Time (CUT).
If you follow the date
command 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 %% (two
percent signs). The date command copies any other characters
to the output without change. The date command always ends
the string with a new-line character.
-n
| Does not set the time globally on all machines in a local area network
that have their clocks synchronized.
|
-u
| Displays or sets the time in Coordinated Universal Time (CUT).
|
%a
| Displays the locale's abbreviated weekday name.
|
%A
| Displays the locale's full weekday name.
|
%b
| Displays the locale's abbreviated month name.
|
%B
| Displays the locale's full month name.
|
%c
| Displays the locale's appropriate date and time
representation. This is the default.
|
%C
| Displays the century as a decimal number (00-99). A year is
divided by 100 and truncated to an integer.
|
%d
| Displays the day of the month as a decimal number (01-31). In a
two-digit field, a 0 is used as leading space fill.
|
%D
| Displays the date in the format equivalent to %m/%d/%y.
|
%e
| Displays the day of the month as a decimal number (1-31). In a
two-digit field, a blank space is used as leading space fill.
|
%h
| Displays the locale's abbreviated month name (a synonym for
%b).
|
%H
| Displays the hour (24-hour clock) as a decimal number (00-23).
|
%I
| Displays the hour (12-hour clock) as a decimal number (01-12).
|
%j
| Displays the day of year as a decimal number (001-366).
|
%m
| Displays the month of year as a decimal number (01-12).
|
%M
| Displays the minutes as a decimal number (00-59).
|
%n
| Inserts a <new-line> character.
|
%p
| Displays the locale's equivalent of either AM or PM.
|
%r
| Displays 12-hour clock time (01-12) using the AM-PM notation; in the
POSIX locale, this is equivalent to %I:%M:%S %p.
|
%S
| Displays the seconds as a decimal number (00- 59).
|
%t
| Inserts a <tab> character.
|
%T
| Displays the 24-hour clock (00-23) in the format equivalent to
HH:MM:SS .
|
%u
| Displays the weekday as a decimal number from 1-7 (Sunday = 7).
Refer to the %w field descriptor.
|
%U
| Displays week of the year(Sunday as the first day of the week) as a
decimal number[00 - 53] . All days in a new year preceding the first
Sunday are considered to be in week 0.
|
%V
| Displays the week of the year as a decimal number from 01-53 (Monday is
used as the first day of the week). If the week containing January 1
has four or more days in the new year, then it is considered week 01;
otherwise, it is week 53 of the previous year.
|
%w
| Displays the weekday as a decimal number from 0-6 (Sunday = 0).
Refer to the %u field descriptor.
|
%W
| Displays the week number of the year as a decimal number (00-53) counting
Monday as the first day of the week.
|
%x
| Displays the locale's appropriate date representation.
|
%X
| Displays the locale's appropriate time representation.
|
%y
| Displays the last two numbers of the year (00-99).
|
%Y
| Displays the year with century as a decimal number.
|
%Z
| Displays the time-zone name, or no characters if no time zone is
determinable.
|
%%
| Displays a % (percent sign) character.
|
The %E and
%O field descriptors can be modified to indicate a different format
or specification, as described in LC_TIME
Category for the Locale Definition Source File Format in AIX 5L
Version 5.1 Files Reference. If the corresponding keyword
(see the era, era_year, era_d_fmt, and
alt_digits keywords) is not specified or not supported for the
current locale, the unmodified field descriptor value is used.
%Ec
| Displays the locale's alternative appropriate date and time
representation.
|
%EC
| Displays the name of the base year (or other time period) in the
locale's alternative representation.
|
%Ex
| Displays the locale's alternative date representation.
|
%EX
| Displays the locale's alternative time representation.
|
%Ey
| Displays the offset from the %EC field descriptor (year only)
in the locale's alternative representation.
|
%EY
| Displays the full alternative year representation.
|
%Od
| Displays the day of the month using the locale's alternative numeric
symbols.
|
%Oe
| Displays the day of the month using the locale's alternative numeric
symbols.
|
%OH
| Displays the hour (24-hour clock) using the locale's alternative
numeric symbols.
|
%OI
| Displays the hour (12-hour clock) using the locale's alternative
numeric symbols.
|
%Om
| Displays the month using the locale's alternative numeric
symbols.
|
%OM
| Displays minutes using the locale's alternative numeric
symbols.
|
%OS
| Displays seconds using the locale's alternative numeric
symbols.
|
%Ou
| Displays the weekday as a number in the locale's alternative
representation (Monday=1).
|
%OU
| Displays the week number of the year using the locale's alternative
numeric symbols. Sunday is considered the first day of the week.
|
%OV
| Displays the week number of the year using the locale's alternative
numeric symbols. Monday is considered the first day of the week.
|
%Ow
| Displays the weekday as a number in the locale's alternative
representation (Sunday =0).
|
%OW
| Displays the week number of the year using the locale's alternative
numeric symbols. Monday is considered the first day of the week.
|
%Oy
| Displays the year (offset from %C) in alternative representation.
|
This command returns the following
exit values:
0
| The date was written successfully.
|
>0
| An error occurred.
|
- To display current date and
time, enter:
date
- To set the date and time,
enter:
date 0217142590
This sets the date and time to Sat Feb 17 14:25:00 CST
1990.
Note: You must have
root authority to change the date and time.
- To display the date and time in
a specified format, enter:
date +"%r %a %d %h %y (Julian Date: %j)"
This displays the date shown in Example 2 as:
02:25:03 PM Fri 17 Feb 90 (Julian Date: 048)
The following environment
variables affect the execution of the date command.
LANG
| Determines the locale to use when both LC_ALL and the
corresponding environment variable (beginning with LC_) do not
specify a locale.
|
LC_ALL
| Determines the locale to be used to override any values for locale
categories specified by the setting of LANG or any environment
variable beginning with LC_.
|
LC_CTYPE
| Determines the locale for the interpretation of sequences of bytes of
text data as characters (for example, single versus multibyte character in an
argument).
|
LC_MESSAGES
| Determines the language in which messages should be written.
|
LC_TIME
| Determines the contents of date and time strings written by
date.
|
NLSPATH
| Determines the location of message catalogues for the processing of
LC_MESSAGES.
|
TZ
| Specifies the time zone in which the time and date are written, unless
the -u option is specified. If the TZ variable is
not set and the -u flag is not specified, an unspecified system
default time zone is used.
|
The environment file.
The localtime subroutine, strftime subroutine, time subroutine.
LC_TIME
Category for the Locale Definition Source File Format in AIX 5L
Version 5.1 Files Reference.
Understanding
Locale in AIX 5L Version 5.1 System Management Concepts:
Operating System and Devices discusses locale values.
[ Previous | Next | Table of Contents | Index |
Library Home |
Legal |
Search ]