Hitachi

Job Management Partner 1 Version 10 Job Management Partner 1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide


date command (displays the system date and time)

Organization of this page

Format

date [-u] [-d date-information-string | -r elapsed-seconds] [+format]

Description

This command displays the system date and time.

Arguments

-u

--utc

--universal

Specifies that the date is to be displayed in UTC (Coordinated Universal Time).

-d date-information-string

--date=date-information-string

Specifies the date and time to be displayed as a date-information string. If more than one information string is specified, the last string specified takes effect. For the supported date-information strings, see Date-information strings that can be specified in the -d option.

-r elapsed-seconds

Specifies that the display is to be of the date and time after the amount of time specified by elapsed-seconds had elapsed since the beginning of the UNIX epoch (UTC January 1, 1970, 00:00:00). The value specified in elapsed-seconds can range from -1009875600 to 2147440447. The output result cannot be guaranteed if the specified value is outside this range.

+format

Specifies a display format for the date and time using format specification codes. The format specification codes for the strftime function (OS's API) can be used. For details about the supported format specification codes, see Supported format specification codes, below.

If this argument is not specified, the display format for the date and time will be %Y/%m/%d %A %H:%M:%S %Z.

Supported format specification codes

In the argument that begins with a plus sign (+), you can specify the format specification codes for the strftime function (OS's API). These format specification codes vary according to the OS. For the format specification codes supported by your OS, see the information about the strftime function in the OS documentation.

The following table lists and describes the typical format specification codes that are supported by all OSs:

Format specification code

Meaning

%a

Abbreviation for the day of the week

%A

Full name for the day of the week

%b

Abbreviation for the month

%B

Full name for the month

%c

Date and time display based on the locale

%d

Day of the month as a decimal number (01 to 31)

%H

Time in the 24-hour clock (00 to 23)

%I

Time in the 12-hour clock (01 to 12)

%j

Number of days since the beginning of the year as a decimal number (001 to 366)

%m

Month as a decimal number (01 to 12)

%M

Minute as a decimal number (00 to 59)

%p

AM or PM based on the current locale

%S

Second as a decimal number. The range of values displayed varies according to the OS depending on support for leap seconds.

%U

Week as a decimal number (00 to 53). The first Sunday of the year begins the weeks.

%w

Day of the week as a decimal number (0 to 6, where 0 indicates Sunday)

%W

Week as a decimal number (00 to 53). The first Monday of the year begins the weeks.

%x

Date based on the current locale

%X

Time based on the current locale

%y

Last two digits of the year as a decimal number (00 to 99)

%Y

Year as four decimal digits

%Z

Time zone name. If the time zone is unknown, this information is not displayed.

%%

Percent symbol (%)

Date-information strings that can be specified in the -d option

Specify as explained below the date-information string that you want the date command to display:

The elements of the date-information string can be specified as uppercase or lowercase letters. If a specified value is earlier than 1970-01-01 00:00:00 or later than 2038-01-19 03:14:07 in UTC, the command issues the error message date: Invalid date: specified-value and then terminates with an error. In AIX, if a specified value is later than 2038-01-19 03:14:07 in the local time zone, the command issues error message date: Invalid date: specified-value and then terminates with an error. If the null character is specified as the date-information string, the command displays 00:00:00 on the current date.

The following explains the permitted elements of a date-information string and the syntax.

The specified absolute and relative date and time values are obtained in the order shown below. In steps 2 through 4, if the value converted to seconds is outside the range from 0 to 2147483647, an error might result regardless of the final results.

  1. Obtains the current date and time or the date and time specified as an absolute date.

  2. Adds the shift in day of week specified as a relative date to the value obtained in step 1. If date specification is specified as an absolute date, the number of days of week to be shifted (DAY) is not added, if specified.

  3. Adds or subtracts all results obtained based on the specified number of years and months to be shifted (DATE) as a relative date to or from the value obtained in step 2.

  4. Adds or subtracts all results obtained based on the specified number of days to be shifted (DATE), number of hours and minutes to be shifted (DATE), and number of seconds to be shifted (DATE) specified as a relative date to or from the value obtained in step 3.

Steps 2 through 4 obtain the amount to be shifted from the date and time subject to calculation.

For example, if the current date and time is 2014-04-30 at 10:10:10 and date -d "Fri, 1 year 1 month 1 day 1 hour 1 min 1 sec" is specified, the following calculation occurs:

1. Obtain the current date and time.

[Figure] The result is 2014-04-30 (Wednesday) at 10:10:10.

2. Add the number of days from 2014-04-30 (Wednesday) to the next Friday.

[Figure] The result is 2014-05-02 (Friday) at 10:10:10.

3. Add 365 days and the number of days in May 2014.

[Figure] The result is 2015-06-02 (Monday) at 10:10:10.

4. Add one day, one hour, one minute, and one second.

[Figure] The result is 2015-06-03 (Tuesday) at 11:11:11.

Return codes

Return code

Meaning

0

Normal termination

1 or greater

Error termination

Notes

Usage examples