DATE(1)DATE(1)NAMEdate - write the date and time
/usr/bin/date [-u] [-R] [+format]
/usr/bin/date [-a [-]sss.fff]
/usr/bin/date [-u] [ [mmdd] HHMM | mmddHHMM [cc] yy] [.SS]
/usr/xpg4/bin/date [-u] [-R] [+format]
/usr/xpg4/bin/date [-a [-]sss.fff]
[ [mmdd] HHMM | mmddHHMM [cc] yy] [.SS]
The date utility writes the date and time to standard output or
attempts to set the system date and time. By default, the current date
and time is written.
Specifications of native language translations of month and weekday
names are supported. The month and weekday names used for a language
are based on the locale specified by the environment variable LC_TIME.
The following is the default form for the "C" locale:
%a %b %e %T %Z %Y
Fri Dec 23 10:10:42 EST 1988
The following options are supported:
Slowly adjust the time by sss.fff seconds (fff
represents fractions of a second). This adjust‐
ment can be positive or negative. The system's
clock is sped up or slowed down until it has
drifted by the number of seconds specified.
Only the super-user may adjust the time.
Display (or set) the date in Greenwich Mean
Time (GMT—universal time), bypassing the normal
conversion to (or from) local time.
Change the default format to the format used
for mail message headers (similar to RFC 822
format). The default format becomes
%a, %d %h %Y %H:%M:%S %z
The following operands are supported:
If the argument begins with +, the output of date is the
result of passing format and the current time to strf‐
time(). date uses the conversion specifications listed on
the strftime(3C) manual page, with the conversion specifi‐
cation for %C determined by whether /usr/bin/date or
/usr/xpg4/bin/date is used:
Locale's date and time representa‐
tion. This is the default output for
Century (a year divided by 100 and
truncated to an integer) as a deci‐
mal number [00-99].
In addition, the nonstandard conversion specification %N is
also supported, and is converted to the zero-padded number
of nanoseconds since the last second. Note that the actual
resolution of this number is limited to the resolution of
the system's CLOCK_REALTIME clock. See clock_gettime(3C).
The string is always terminated with a NEWLINE. An argument
containing blanks must be quoted; see the EXAMPLES section.
Day number in the month
Hour number (24 hour system)
Century (a year divided by 100 and truncated to an integer)
as a decimal number [00-99]. For example, cc is 19 for the
year 1988 and 20 for the year 2007.
Last two digits of the year number. If century (cc) is not
specified, then values in the range 69-99 shall refer to
years 1969 to 1999 inclusive, and values in the range 00-68
shall refer to years 2000 to 2068, inclusive.
The month, day, year number, and century may be omitted; the current
values are applied as defaults. For example, the following entry:
example% date 10080045
sets the date to Oct 8, 12:45 a.m. The current year is the default
because no year is supplied. The system operates in GMT. date takes
care of the conversion to and from local standard and daylight time.
Only the super-user may change the date. After successfully setting the
date and time, date displays the new date according to the default for‐
mat. The date command uses TZ to determine the correct time zone infor‐
mation; see environ(5).
Example 1 Generating Output
The following command:
example% date '+DATE: %m/%d/%y%nTIME:%H:%M:%S'
generates as output
Example 2 Setting the Current Time
The following command sets the current time to 12:34:56:
example# date 1234.56
Example 3 Setting Another Time and Date in Greenwich Mean Time
The following command sets the date to January 1st, 12:30 am, 2000:
example# date-u 010100302000
This is displayed as:
Thu Jan 01 00:30:00 GMT 2000
See environ(5) for descriptions of the following environment variables
that affect the execution of date: LANG, LC_ALL, LC_CTYPE, LC_TIME,
LC_MESSAGES, and NLSPATH.
Determine the timezone in which the time and date are written,
unless the -u option is specified. If the TZ variable is not set
and the -u is not specified, the system default timezone is
The following exit values are returned:
An error occurred.
See attributes(5) for descriptions of the following attributes:
│ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
│CSI │ enabled │
│ ATTRIBUTE TYPE │ ATTRIBUTE VALUE │
│CSI │ enabled │
│Interface Stability │ Standard │
SEE ALSOstrftime(3C), attributes(5), environ(5), standards(5)DIAGNOSTICS
You are not the super-user and you tried to change
The date set is syntactically incorrect.
If you attempt to set the current date to one of the dates that the
standard and alternate time zones change (for example, the date that
daylight time is starting or ending), and you attempt to set the time
to a time in the interval between the end of standard time and the
beginning of the alternate time (or the end of the alternate time and
the beginning of standard time), the results are unpredictable.
Using the date command from within windowing environments to change the
date can lead to unpredictable results and is unsafe. It can also be
unsafe in the multi-user mode, that is, outside of a windowing system,
if the date is changed rapidly back and forth. The recommended method
of changing the date is 'date -a'.
Setting the system time or allowing the system time to progress beyond
03:14:07 UTC Jan 19, 2038 is not supported on Solaris.
May 1, 2011 DATE(1)