Move everything from /var/adm to /var/log
[unleashed.git] / share / man / man1 / date.1
blobe7af7f2700b3a877138494446af90af8aa1b9122
1 .\"
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/.
6 .\"
7 .\" The Institute of Electrical and Electronics Engineers and The Open
8 .\" Group, have given us permission to reprint portions of their
9 .\" documentation.
10 .\"
11 .\" In the following statement, the phrase ``this text'' refers to portions
12 .\" of the system documentation.
13 .\"
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.
24 .\"
25 .\" This notice shall appear on any product containing this material.
26 .\"
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.
30 .\"
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.
35 .\"
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]
41 .\"
42 .\"
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.
48 .\"
49 .TH DATE 1 "Dec 6, 2017"
50 .SH NAME
51 date \- write the date and time
52 .SH SYNOPSIS
53 .LP
54 .nf
55 \fB/usr/bin/date\fR [\fB-u\fR] [\fB-r\fR \fIseconds\fR | \fIfilename\fR] [\fB-R\fR] [+\fIformat\fR]
56 .fi
58 .LP
59 .nf
60 \fB/usr/bin/date\fR [\fB-a\fR [-]\fIsss.fff\fR]
61 .fi
63 .LP
64 .nf
65 \fB/usr/bin/date\fR [\fB-u\fR]
66      [ [\fImmdd\fR] \fIHHMM\fR | \fImmddHHMM\fR [\fIcc\fR] \fIyy\fR] [\fI\&.SS\fR]
67 .fi
69 .SH DESCRIPTION
70 .LP
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
73 written.
74 .sp
75 .LP
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
79 \fBenviron\fR(5).
80 .sp
81 .LP
82 The following is the default form for the "C" locale:
83 .sp
84 .in +2
85 .nf
86 \fI%a %b %e %T %Z %Y\fR
87 .fi
88 .in -2
90 .sp
91 .LP
92 For example,
93 .sp
94 .in +2
95 .nf
96 Fri Dec 23 10:10:42 EST 1988
97 .fi
98 .in -2
99 .sp
101 .SH OPTIONS
103 The following options are supported:
105 .ne 2
107 \fB\fB-a\fR [\|\fB-\fR\|]\|\fIsss.fff\fR \fR
109 .RS 24n
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.
117 .ne 2
119 \fB\fB-r\fR \fIseconds\fR\fR
121 .RS 24n
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).
128 .ne 2
130 \fB\fB-r\fR \fIfilename\fR\fR
132 .RS 24n
133 Rather than using the current time, obtain the time based on
134 the modification time of \fIfilename\fR.
138 .ne 2
140 \fB-R\fR
142 .RS 24n
143 Change the default format to the format used for mail message headers
144 (similar to RFC 822 format).  The default format becomes
146 .in +2
148 \fI%a, %d %h %Y %H:%M:%S %z\fR
150 .in -2
154 .ne 2
156 \fB\fB-u\fR \fR
158 .RS 24n
159 Display (or set) the date in Greenwich Mean Time (GMT\(emuniversal time),
160 bypassing the normal conversion to (or from) local time.
163 .SH OPERANDS
165 The following operands are supported:
167 .ne 2
169 \fB\fB+\fR\fIformat\fR \fR
171 .RS 12n
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:
177 .ne 2
180 .RS 3n
181 Century (a year divided by 100 and truncated to an integer) as a decimal number
182 [00-99].
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.
196 .ne 2
198 \fB\fImm\fR \fR
200 .RS 12n
201 Month number
205 .ne 2
207 \fB\fIdd\fR \fR
209 .RS 12n
210 Day number in the month
214 .ne 2
216 \fB\fIHH\fR \fR
218 .RS 12n
219 Hour number (24 hour system)
223 .ne 2
225 \fB\fIMM\fR \fR
227 .RS 12n
228 Minute number
232 .ne 2
234 \fB\fISS\fR \fR
236 .RS 12n
237 Second number
241 .ne 2
243 \fB\fIcc\fR \fR
245 .RS 12n
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
248 the year 2007.
252 .ne 2
254 \fB\fIyy\fR \fR
256 .RS 12n
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
260 2068, inclusive.
265 The month, day, year number, and century may be omitted; the current values are
266 applied as defaults. For example, the following entry:
268 .in +2
270 example% \fBdate 10080045\fR
272 .in -2
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
283 \fBenviron\fR(5).
284 .SH EXAMPLES
286 \fBExample 1 \fRGenerating Output
289 The following command:
292 .in +2
294 example% \fBdate '+DATE: %m/%d/%y%nTIME:%H:%M:%S'\fR
296 .in -2
301 generates as output
304 .in +2
306 DATE: 08/01/76
308 TIME: 14:45:05
310 .in -2
314 \fBExample 2 \fRSetting the Current Time
317 The following command sets the current time to \fB12:34:56\fR:
320 .in +2
322 example# \fBdate 1234.56\fR
324 .in -2
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:
334 .in +2
336 example# \fBdate -u 010100302000\fR
338 .in -2
343 This is displayed as:
346 .in +2
348 Thu Jan 01 00:30:00 GMT 2000
350 .in -2
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.
359 .ne 2
361 \fB\fBTZ\fR \fR
363 .RS 7n
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.
369 .SH EXIT STATUS
371 The following exit values are returned:
373 .ne 2
375 \fB\fB0\fR \fR
377 .RS 7n
378 Successful completion.
382 .ne 2
384 \fB\fB>0\fR \fR
386 .RS 7n
387 An error occurred.
390 .SH ATTRIBUTES
392 See \fBattributes\fR(5) for descriptions of the following attributes:
393 .SS "/usr/bin/date"
396 box;
397 c | c
398 l | l .
399 ATTRIBUTE TYPE  ATTRIBUTE VALUE
401 CSI     enabled
403 Interface Stability     Standard
406 .SH SEE ALSO
408 \fBstrftime\fR(3C), \fBattributes\fR(5), \fBenviron\fR(5), \fBstandards\fR(5)
409 .SH DIAGNOSTICS
410 .ne 2
412 \fB\fBno permission\fR \fR
414 .RS 19n
415 You are not the super-user and you tried to change the date.
419 .ne 2
421 \fB\fBbad conversion\fR \fR
423 .RS 19n
424 The date set is syntactically incorrect.
427 .SH NOTES
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
434 are unpredictable.
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.