date

NAME

date - set or display date and time

SYNOPSIS

date [-u] [-r seconds] [+format]

date [-u] -t [[[[[CC]yy]mm]dd]HH]MM[.SS] [+format]

date [-u] [+format] mmddHHMM[yy]

DESCRIPTION

The date(1) utility displays the current date and time when invoked without arguments. Providing arguments will format the date and time in a user-defined way.

If the argument provided is the month (mm, as a number), day (dd), hour (HH, as a number using the 24-hour system), minute (MM) and optionally the year (yy--current year if omitted), the utility attempts to set the system date and time. Only a user with appropriate privileges may set the date.

OPTIONS

-r seconds
Display the date and time in seconds from the UNIX Epoch (January 1, 1970)
-t [[[[[CC]yy]mm]dd]HH]MM[.SS]
Set the time and date for minutes west of Greenwich mean time (GMT). This value is the number of minutes that is returned in the tz_minuteswest member in calls to gettimeofday(2). Only the minutes (MM) are required; hours (HH), days (dd), month (mm), the century (CC), and seconds (SS) are all optional.
-u
Display the date in Universal Coordinated Time (UCT).
+format
Display the date and time in the format specified by format. Format can contain arbitrary text and any of the following conversion specifications:
%A The full weekday name.
%a The abbreviated weekday name, where the abbreviation is the first three characters.
%B The full month name.
%b or %h The abbreviated month name, where the abbreviation is the first three characters.
%C The first two digits of the year, indicating the century.
%c Equivalent to %m/%d/%y.
%D The date in the format mm/dd/yy.
%d The day of the month as a decimal number (01-31).
%e The day of month as a decimal number (1-31); single digits are preceded by a blank.
%H The hour (24-hour clock) as a decimal number (00-23).
%I The hour (12-hour clock) as a decimal number (01-12).
%j The day of the year as a decimal number (001-366).
%k The hour (24-hour clock) as a decimal number (0-23); single digits are preceded by a blank.
%l The hour (12-hour clock) as a decimal number (1-12); single digits are preceded by a blank.
%M The minute as a decimal number (00-59).
%m The month as a decimal number (01-12).
%n A newline.
%p Either A.M. or P.M., as appropriate.
%R Equivalent to %H:%M.
%r Equivalent to %I:%M:%S%p.
%t A tab character.
%S The second as a decimal number (00-60).
%T Equivalent to %H:%M:%S.
%U The week number of the year as a decimal number (00-53), where Sunday is the first day of the week.
%W The week number of the year as a decimal number (00-53), where Monday is the first day of the week.
%w The weekday as a decimal number (0-6), where Sunday is the first day of the week.
%X The locale's appropriate time representation.
%x The locale's appropriate date representation.
%Y The year with century as a decimal number.
%y The year without century as a decimal number (00-99).
%Z The time zone name.
%% Prints a percent character (%).

The format string for the default display is:

%a %b %e %H:%M:%S %Z %Y%n

NOTES

Only users who have been granted the permission SE_SYSTEMTIME_PRIVILEGE can set the date and time.

The specifiers %c, %D, %x, and %y all represent the year as a two-digit variable. Examine any shell scripts that make use of this output to ensure that they will function correctly.

In the POSIX or C locale, the appropriate date representation is %m/%d/%y; the appropriate time representation is %H:%M:%S.

EXAMPLES

The command:
date "+DATE: %m/%d/%y%nTIME: %H:%M:%S"

will display:

DATE: 11/21/87
TIME: 13:36:16

ENVIRONMENT VARIABLES

The following environment variables affect the execution of date(1):
TZ The time zone to use when displaying dates.

DIAGNOSTICS

The date(1) utility exits with these values:
0 Success
>0 An error occurred.

SEE ALSO

ctime(3)

printf(3)