2 .\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for
3 .\" permission to reproduce portions of its copyrighted documentation.
4 .\" Original documentation from The Open Group can be obtained online at
5 .\" http://www.opengroup.org/bookstore/.
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
14 .\" Portions of this text are reprinted and reproduced in electronic form
15 .\" in the SunOS Reference Manual, from IEEE Std 1003.1, 2004 Edition,
16 .\" Standard for Information Technology -- Portable Operating System
17 .\" Interface (POSIX), The Open Group Base Specifications Issue 6,
18 .\" Copyright (C) 2001-2004 by the Institute of Electrical and Electronics
19 .\" Engineers, Inc and The Open Group. In the event of any discrepancy
20 .\" between these versions and the original IEEE and The Open Group
21 .\" Standard, the original IEEE and The Open Group Standard is the referee
22 .\" document. The original Standard can be obtained online at
23 .\" http://www.opengroup.org/unix/online.html.
25 .\" This notice shall appear on any product containing this material.
27 .\" The contents of this file are subject to the terms of the
28 .\" Common Development and Distribution License (the "License").
29 .\" You may not use this file except in compliance with the License.
31 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
32 .\" or http://www.opensolaris.org/os/licensing.
33 .\" See the License for the specific language governing permissions
34 .\" and limitations under the License.
36 .\" When distributing Covered Code, include this CDDL HEADER in each
37 .\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
38 .\" If applicable, add the following below this CDDL HEADER, with the
39 .\" fields enclosed by brackets "[]" replaced with your own identifying
40 .\" information: Portions Copyright [yyyy] [name of copyright owner]
43 .\" Copyright 1989 AT&T
44 .\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
45 .\" Copyright (c) 2004, Sun Microsystems, Inc. All Rights Reserved
46 .\" Copyright 2011 Nexenta Systems, Inc. All rights reserved.
47 .\" Copyright (c) 2017 Joyent, Inc.
49 .TH DATE 1 "Dec 6, 2017"
51 date \- write the date and time
55 \fB/usr/bin/date\fR [\fB-u\fR] [\fB-r\fR \fIseconds\fR | \fIfilename\fR] [\fB-R\fR] [+\fIformat\fR]
60 \fB/usr/bin/date\fR [\fB-a\fR [-]\fIsss.fff\fR]
65 \fB/usr/bin/date\fR [\fB-u\fR]
66 [ [\fImmdd\fR] \fIHHMM\fR | \fImmddHHMM\fR [\fIcc\fR] \fIyy\fR] [\fI\&.SS\fR]
71 The \fBdate\fR utility writes the date and time to standard output or attempts
72 to set the system date and time. By default, the current date and time is
76 Specifications of native language translations of month and weekday names are
77 supported. The month and weekday names used for a language are based on the
78 locale specified by the environment variable \fBLC_TIME\fR. See
82 The following is the default form for the "C" locale:
86 \fI%a %b %e %T %Z %Y\fR
96 Fri Dec 23 10:10:42 EST 1988
103 The following options are supported:
107 \fB\fB-a\fR [\|\fB-\fR\|]\|\fIsss.fff\fR \fR
110 Slowly adjust the time by \fIsss\fR.\fIfff\fR seconds (\fIfff\fR represents
111 fractions of a second). This adjustment can be positive or negative. The
112 system's clock is sped up or slowed down until it has drifted by the number of
113 seconds specified. Only the super-user may adjust the time.
119 \fB\fB-r\fR \fIseconds\fR\fR
122 Rather than using the current time, obtain the time based on
123 \fIseconds\fR. \fIseconds\fR will be treated as time since the UNIX
124 Epoch (00:00:00 UTC, January 1, 1970).
130 \fB\fB-r\fR \fIfilename\fR\fR
133 Rather than using the current time, obtain the time based on
134 the modification time of \fIfilename\fR.
143 Change the default format to the format used for mail message headers
144 (similar to RFC 822 format). The default format becomes
148 \fI%a, %d %h %Y %H:%M:%S %z\fR
159 Display (or set) the date in Greenwich Mean Time (GMT\(emuniversal time),
160 bypassing the normal conversion to (or from) local time.
165 The following operands are supported:
169 \fB\fB+\fR\fIformat\fR \fR
172 If the argument begins with \fB+\fR, the output of \fBdate\fR is the result of
173 passing \fIformat\fR and the current time to \fBstrftime()\fR. \fBdate\fR uses
174 the conversion specifications listed on the \fBstrftime\fR(3C) manual page.
175 Next conversion specification for \fB%C\fR is used:
181 Century (a year divided by 100 and truncated to an integer) as a decimal number
185 In addition, the nonstandard conversion specification \fB%N\fR is also
186 supported, and is converted to the zero-padded number of nanoseconds since the
187 last second. Note that the actual resolution of this number is limited to the
188 resolution of the system's \fBCLOCK_REALTIME\fR clock. See
189 \fBclock_gettime\fR(3C).
191 The string is always terminated with a NEWLINE. An argument containing blanks
192 must be quoted; see the EXAMPLES section.
210 Day number in the month
219 Hour number (24 hour system)
246 Century (a year divided by 100 and truncated to an integer) as a decimal number
247 [00-99]. For example, \fIcc\fR is \fB19\fR for the year 1988 and \fB20\fR for
257 Last two digits of the year number. If century (\fIcc\fR) is not specified,
258 then values in the range \fB69-99\fR shall refer to years 1969 to 1999
259 inclusive, and values in the range \fB00-68\fR shall refer to years 2000 to
265 The month, day, year number, and century may be omitted; the current values are
266 applied as defaults. For example, the following entry:
270 example% \fBdate 10080045\fR
277 sets the date to Oct 8, 12:45 a.m. The current year is the default because no
278 year is supplied. The system operates in GMT. \fBdate\fR takes care of the
279 conversion to and from local standard and daylight time. Only the super-user
280 may change the date. After successfully setting the date and time, \fBdate\fR
281 displays the new date according to the default format. The \fBdate\fR command
282 uses \fBTZ\fR to determine the correct time zone information; see
286 \fBExample 1 \fRGenerating Output
289 The following command:
294 example% \fBdate '+DATE: %m/%d/%y%nTIME:%H:%M:%S'\fR
314 \fBExample 2 \fRSetting the Current Time
317 The following command sets the current time to \fB12:34:56\fR:
322 example# \fBdate 1234.56\fR
328 \fBExample 3 \fRSetting Another Time and Date in Greenwich Mean Time
331 The following command sets the date to January 1st, 12:30 am, 2000:
336 example# \fBdate -u 010100302000\fR
343 This is displayed as:
348 Thu Jan 01 00:30:00 GMT 2000
353 .SH ENVIRONMENT VARIABLES
355 See \fBenviron\fR(5) for descriptions of the following environment variables
356 that affect the execution of \fBdate\fR: \fBLANG\fR, \fBLC_ALL\fR,
357 \fBLC_CTYPE\fR, \fBLC_TIME\fR, \fBLC_MESSAGES\fR, and \fBNLSPATH\fR.
364 Determine the timezone in which the time and date are written, unless the
365 \fB-u\fR option is specified. If the \fBTZ\fR variable is not set and the
366 \fB-u\fR is not specified, the system default timezone is used.
371 The following exit values are returned:
378 Successful completion.
392 See \fBattributes\fR(5) for descriptions of the following attributes:
399 ATTRIBUTE TYPE ATTRIBUTE VALUE
403 Interface Stability Standard
408 \fBstrftime\fR(3C), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)
412 \fB\fBno permission\fR \fR
415 You are not the super-user and you tried to change the date.
421 \fB\fBbad conversion\fR \fR
424 The date set is syntactically incorrect.
429 If you attempt to set the current date to one of the dates that the standard
430 and alternate time zones change (for example, the date that daylight time is
431 starting or ending), and you attempt to set the time to a time in the interval
432 between the end of standard time and the beginning of the alternate time (or
433 the end of the alternate time and the beginning of standard time), the results
437 Using the \fBdate\fR command from within windowing environments to change the
438 date can lead to unpredictable results and is unsafe. It can also be unsafe in
439 the multi-user mode, that is, outside of a windowing system, if the date is
440 changed rapidly back and forth. The recommended method of changing the date
441 is '\fBdate\fR \fB-a\fR'.
444 Setting the system time or allowing the system time to progress beyond
445 \fB03:14:07 UTC Jan 19, 2038\fR is not supported on Solaris.