Initial import, 0.1 + pk 0.2.4-B1
[unix-history] / bin / date / date.1
CommitLineData
15637ed4
RG
1.\" Copyright (c) 1980, 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" the Institute of Electrical and Electronics Engineers, Inc.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\" notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\" notice, this list of conditions and the following disclaimer in the
14.\" documentation and/or other materials provided with the distribution.
15.\" 3. All advertising materials mentioning features or use of this software
16.\" must display the following acknowledgement:
17.\" This product includes software developed by the University of
18.\" California, Berkeley and its contributors.
19.\" 4. Neither the name of the University nor the names of its contributors
20.\" may be used to endorse or promote products derived from this software
21.\" without specific prior written permission.
22.\"
23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33.\" SUCH DAMAGE.
34.\"
35.\" @(#)date.1 6.16 (Berkeley) 7/30/91
36.\"
37.Dd July 30, 1991
38.Dt DATE 1
39.Os
40.Sh NAME
41.Nm date
42.Nd Display or set date and time
43.Sh SYNOPSIS
44.Nm date
45.Op Fl d Ar dst
46.Op Fl r Ar seconds
47.Op Fl t Ar minutes_west
48.Op Fl nu
49.Op Cm + Ns Ar format
50.Op [yy[mm[dd[hh]]]]mm[\&.ss]
51.Sh DESCRIPTION
52.Nm Date
53displays the current date and time when invoked without arguments.
54Providing arguments will format the date and time in a user-defined
55way or set the date.
56Only the superuser may set the date.
57.Pp
58The options are as follows:
59.Bl -tag -width Ds
60.It Fl d
61Set the kernel's values for daylight savings time.
62If
63.Ar dst
64is non-zero, future calls
65to
66.Xr gettimeofday 2
67will return a non-zero
68.Ql tz_dsttime .
69.It Fl n
70The utility
71.Xr timed 8
72is used to synchronize the clocks of groups of machines.
73By default, if
74.Xr timed
75is running,
76.Nm date
77will set the time on all of the machines in the local group.
78The
79.Fl n
80option stops
81.Nm date
82from setting the time for other than the current machine.
83.It Fl r
84Print out the date and time for
85.Ar seconds
86from the Epoch.
87.It Fl t
88Set the kernel's values for minutes west of
89.Tn GMT .
90.Ar Minutes_west
91specifies the number of minutes returned in
92.Ql tz_minuteswest
93by future calls to
94.Xr gettimeofday 2 .
95.It Fl u
96Display or set the date in
97.Tn UCT
98(universal) time.
99.El
100.Pp
101An operand with a leading plus (``+'') sign signals a user-defined format
102string which specifies the format in which to display the date and time.
103The format string may contain any of the conversion specifications described
104in the
105.Xr strftime 3
106manual page, as well as any arbitrary text.
107The format string for the default display is:
108.Bd -literal -offset indent
109``%a %b %e %H:%M:%S %Z n''.
110.Ed
111.Pp
112If an operand does not have a leading plus sign, it is interpreted as
113a value for setting the system's notion of the current date and time.
114The canonical representation for setting the date and time:
115.Pp
116.Bl -tag -width Ds -compact -offset indent
117.It Ar yy
118Year in abbreviated form (.e.g 89 for 1989).
119.It Ar mm
120Numeric month.
121A number from 1 to 12.
122.It Ar dd
123Day, a number from 1 to 31.
124.It Ar hh
125Hour, a number from 0 to 23.
126.It Ar mm
127Minutes, a number from 0 to 59.
128.It Ar .ss
129Seconds, a number from 0 to 59.
130.El
131.Pp
132Everything but the minutes are optional.
133.Pp
134Time changes for Daylight Saving and Standard time and leap seconds
135and years are handled automatically.
136.Sh EXAMPLES
137The command:
138.Bd -literal -offset indent
139date ``+DATE: %m/%d/%y%nTIME: %H:%M:%n''
140.Ed
141.Pp
142will display:
143.Bd -literal -offset indent
144DATE: 11/21/87
145TIME: 13:36:16
146.Ed
147.Pp
148The command:
149.Bd -literal -offset indent
150date 8506131627
151.Ed
152.Pp
153sets the date to
154.Dq Li "June 13 1985, 4:27 PM" .
155.Pp
156The command:
157.Bd -literal -offset indent
158date 1432
159.Ed
160.Pp
161sets the time to
162.Li "2:32 PM" ,
163without modifying the date.
164.Sh FILES
165.Bl -tag -width /var/log/messages -compact
166.It Pa /var/log/wtmp
167A record of date resets and time changes.
168.It Pa /var/log/messages
169A record of the user setting the time.
170.El
171.Sh SEE ALSO
172.Xr gettimeofday 2 ,
173.Xr strftime 3 ,
174.Xr utmp 5 ,
175.Xr timed 8
176.Rs
177.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
178.%A R. Gusella
179.%A S. Zatti
180.Re
181.Sh DIAGNOSTICS
182Exit status is 0 on success, 1 if unable to set the date, and 2
183if able to set the local date but failing to set it globally.
184.Pp
185Occasionally, when
186.Xr timed
187synchronizes the time on many hosts, the setting of a new time value may
188require more than a few seconds.
189On these occasions,
190.Nm date
191prints:
192.Ql Network time being set .
193The message
194.Ql Communication error with timed
195occurs when the communication
196between
197.Nm date
198and
199.Xr timed
200fails.
201.Sh BUGS
202The system attempts to keep the date in a format closely compatible
203with
204.Tn VMS .
205.Tn VMS ,
206however, uses local time (rather than
207.Tn GMT )
208and does not understand
209daylight-saving time.
210Thus, if you use both
211.Tn UNIX
212and
213.Tn VMS ,
214.Tn VMS
215will be running on
216.Tn GMT .
217.Sh HISTORY
218The
219.Nm date
220command is expected to be compatible with
221.St p1003.2 .