date [-u] [-r seconds] [+format]
date [-u] -t [[[[[CC]yy]mm]dd]HH]MM[.SS] [+format]
date [-u] [+format] mmddHHMM[yy]
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.
%A | The full weekday name. |
%a | The abbreviated weekday name, where the abbreviation is the first three characters. |
%B | The full month name. |
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
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.
date "+DATE: %m/%d/%y%nTIME: %H:%M:%S"
will display:
DATE: 11/21/87
TIME: 13:36:16
TZ | The time zone to use when displaying dates. |
0 | Success |
>0 | An error occurred. |
ctime(3)
printf(3)