xref: /original-bsd/bin/date/date.1 (revision ce06cd54)
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.\" %sccs.include.redist.roff%
8.\"
9.\"     @(#)date.1	6.17 (Berkeley) 03/20/92
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 values 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 of 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 for
59.Ar seconds
60from the Epoch.
61.It Fl t
62Set the kernel's values 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:
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 are 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:%n''
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 FILES
139.Bl -tag -width /var/log/messages -compact
140.It Pa /var/log/wtmp
141A record of date resets and time changes.
142.It Pa /var/log/messages
143A record of the user setting the time.
144.El
145.Sh SEE ALSO
146.Xr gettimeofday 2 ,
147.Xr strftime 3 ,
148.Xr utmp 5 ,
149.Xr timed 8
150.Rs
151.%T "TSP: The Time Synchronization Protocol for UNIX 4.3BSD"
152.%A R. Gusella
153.%A S. Zatti
154.Re
155.Sh DIAGNOSTICS
156Exit status is 0 on success, 1 if unable to set the date, and 2
157if able to set the local date but failing to set it globally.
158.Pp
159Occasionally, when
160.Xr timed
161synchronizes the time on many hosts, the setting of a new time value may
162require more than a few seconds.
163On these occasions,
164.Nm date
165prints:
166.Ql Network time being set .
167The message
168.Ql Communication error with timed
169occurs when the communication
170between
171.Nm date
172and
173.Xr timed
174fails.
175.Sh BUGS
176The system attempts to keep the date in a format closely compatible
177with
178.Tn VMS .
179.Tn VMS ,
180however, uses local time (rather than
181.Tn GMT )
182and does not understand
183daylight-saving time.
184Thus, if you use both
185.Tn UNIX
186and
187.Tn VMS ,
188.Tn VMS
189will be running on
190.Tn GMT .
191.Sh HISTORY
192The
193.Nm date
194command is expected to be compatible with
195.St -p1003.2 .
196