xref: /original-bsd/bin/date/date.1 (revision 95ecee29)
1.\" Copyright (c) 1980, 1990, 1993
2.\"	The Regents of the University of California.  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.\" %sccs.include.redist.roff%
8.\"
9.\"     @(#)date.1	8.2 (Berkeley) 11/17/93
10.\"
11.Dd
12.Dt DATE 1
13.Os
14.Sh NAME
15.Nm date
16.Nd display or set date and time
17.Sh SYNOPSIS
18.Nm date
19.Op Fl d Ar dst
20.Op Fl r Ar seconds
21.Op Fl t Ar minutes_west
22.Op Fl nu
23.Op Cm + Ns Ar format
24.Op [yy[mm[dd[hh]]]]mm[\&.ss]
25.Sh DESCRIPTION
26.Nm Date
27displays the current date and time when invoked without arguments.
28Providing arguments will format the date and time in a user-defined
29way or set the date.
30Only the superuser may set the date.
31.Pp
32The options are as follows:
33.Bl -tag -width Ds
34.It Fl d
35Set the kernel's value for daylight savings time.
36If
37.Ar dst
38is non-zero, future calls
39to
40.Xr gettimeofday 2
41will return a non-zero
42.Ql tz_dsttime  .
43.It Fl n
44The utility
45.Xr timed 8
46is used to synchronize the clocks on groups of machines.
47By default, if
48.Xr timed
49is running,
50.Nm date
51will set the time on all of the machines in the local group.
52The
53.Fl n
54option stops
55.Nm date
56from setting the time for other than the current machine.
57.It Fl r
58Print out the date and time in
59.Ar seconds
60from the Epoch.
61.It Fl t
62Set the kernel's value for minutes west of
63.Tn GMT .
64.Ar Minutes_west
65specifies the number of minutes returned in
66.Ql tz_minuteswest
67by future calls to
68.Xr gettimeofday 2 .
69.It Fl u
70Display or set the date in
71.Tn UCT
72(universal) time.
73.El
74.Pp
75An operand with a leading plus (``+'') sign signals a user-defined format
76string which specifies the format in which to display the date and time.
77The format string may contain any of the conversion specifications described
78in the
79.Xr strftime 3
80manual page, as well as any arbitrary text.
81The format string for the default display is:
82.Bd -literal -offset indent
83``%a %b %e %H:%M:%S %Z n''.
84.Ed
85.Pp
86If an operand does not have a leading plus sign, it is interpreted as
87a value for setting the system's notion of the current date and time.
88The canonical representation for setting the date and time is:
89.Pp
90.Bl -tag -width Ds -compact -offset indent
91.It Ar yy
92Year in abbreviated form (.e.g 89 for 1989).
93.It Ar mm
94Numeric month.
95A number from 1 to 12.
96.It Ar dd
97Day, a number from 1 to 31.
98.It Ar hh
99Hour, a number from 0 to 23.
100.It Ar mm
101Minutes, a number from 0 to 59.
102.It Ar .ss
103Seconds, a number from 0 to 61 (59 plus a a maximum of two leap seconds).
104.El
105.Pp
106Everything but the minutes is optional.
107.Pp
108Time changes for Daylight Saving and Standard time and leap seconds
109and years are handled automatically.
110.Sh EXAMPLES
111The command:
112.Bd -literal -offset indent
113date ``+DATE: %m/%d/%y%nTIME: %H:%M:0n''
114.Ed
115.Pp
116will display:
117.Bd -literal -offset indent
118DATE: 11/21/87
119TIME: 13:36:16
120.Ed
121.Pp
122The command:
123.Bd -literal -offset indent
124date 8506131627
125.Ed
126.Pp
127sets the date to
128.Dq Li "June 13, 1985, 4:27 PM" .
129.Pp
130The command:
131.Bd -literal -offset indent
132date 1432
133.Ed
134.Pp
135sets the time to
136.Li "2:32 PM" ,
137without modifying the date.
138.Sh ENVIRONMENTAL VARIABLES
139The following environment variables affect the execution of
140.Nm date :
141.Bl -tag -width TZ
142.It Ev TZ
143The timezone to use when displaying dates.
144See
145.Xr environ 7
146for more information.
147.El
148.Sh FILES
149.Bl -tag -width /var/log/messages -compact
150.It Pa /var/log/wtmp
151A record of date resets and time changes.
152.It Pa /var/log/messages
153A record of the user setting the time.
154.El
155.Sh SEE ALSO
156.Xr gettimeofday 2 ,
157.Xr strftime 3 ,
158.Xr utmp 5 ,
159.Xr timed 8
160.Rs
161.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
162.%A R. Gusella
163.%A S. Zatti
164.Re
165.Sh DIAGNOSTICS
166Exit status is 0 on success, 1 if unable to set the date, and 2
167if able to set the local date, but unable to set it globally.
168.Pp
169Occasionally, when
170.Xr timed
171synchronizes the time on many hosts, the setting of a new time value may
172require more than a few seconds.
173On these occasions,
174.Nm date
175prints:
176.Ql Network time being set .
177The message
178.Ql Communication error with timed
179occurs when the communication
180between
181.Nm date
182and
183.Xr timed
184fails.
185.Sh BUGS
186The system attempts to keep the date in a format closely compatible
187with
188.Tn VMS .
189.Tn VMS ,
190however, uses local time (rather than
191.Tn GMT )
192and does not understand daylight-savings time.
193Thus, if you use both
194.Tn UNIX
195and
196.Tn VMS ,
197.Tn VMS
198will be running on
199.Tn GMT .
200.Sh STANDARDS
201The
202.Nm date
203command is expected to be compatible with
204.St -p1003.2 .
205